Skip to content

Commit

Permalink
ci: add test (#3)
Browse files Browse the repository at this point in the history
* add test

* put in quotes

* local action

* few assertions

* add current branch back

* use br as delimiter

* update docs
  • Loading branch information
nielstenboom authored Feb 12, 2023
1 parent 8d08e5a commit 2a58bd4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'test action'
on: 'pull_request'
jobs:
test:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get branch name
id: get_branch_name
uses: tj-actions/branch-names@v6

# use the action as it is on the current branch of this PR
- name: Generate changelog
id: changelog
uses: ./
with:
base: '2fd5d62' # first commit of this repo
head: 'origin/${{ steps.get_branch_name.outputs.current_branch }}'

- name: Assertions
shell: python
run: |
changelog = """
${{ steps.changelog.outputs.changelog }}
"""
print(changelog)
assert "## Features 🔨" in changelog
assert "## Fixes 🐛" in changelog
assert "## Other changes 📝" in changelog
assert "## Chores 👷‍♂️" in changelog
assert len(changelog.split("\n")) > 20
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ The generated changelog
with:
fetch-depth: 0

- uses: nielstenboom/[email protected].0
- uses: nielstenboom/[email protected].1
id: changelog
with:
base: main
head: v1.0.0
base: v1.0.0
head: main

- name: Get the changelog
run: |
Expand All @@ -53,7 +53,7 @@ NOTE: if you want to enter branches with forward slashes in them, you should add
fetch-depth: 0

# point to branch with forward slashes with 'origin' prepended
- uses: nielstenboom/[email protected].0
- uses: nielstenboom/[email protected].1
id: changelog
with:
base: v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def main(base: str, head: str):

output = "\n".join(output_lines)

# use 'nl' as delimeiter for gh actions output
# use '<br>' as delimiter for gh actions output
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
output_file = Path(os.environ.get("GITHUB_OUTPUT", "output.txt"))
output_file.write_text(f"changelog<<nl\n{output}\nnl")
output_file.write_text(f"changelog<<<br>\n{output}\n<br>")

if __name__ == "__main__":
main(sys.argv[1], sys.argv[2])

0 comments on commit 2a58bd4

Please sign in to comment.