Skip to content

Commit

Permalink
feat: add tests for checking if action has been bumped
Browse files Browse the repository at this point in the history
  • Loading branch information
Shurtu-gal committed Jan 11, 2024
1 parent dd0ba8c commit 0753be5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
25 changes: 18 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,27 @@ export GITHUB_WORKSPACE = $(shell pwd)
run:
@bash ./entrypoint.sh $(DEFAULT_VERSION) $(DEFAULT_COMMAND) $(TEST_FILEPATH) $(DEFAULT_TEMPLATE) $(DEFAULT_LANGUAGE) $(DEFAULT_OUTPUT) $(DEFAULT_PARAMETERS) $(DEFAULT_CUSTOM_COMMANDS)

# Updates the action.yml file with the latest version of the action got from $VERSION env variable
generate-assets:
version=$$(echo ${VERSION} | sed 's/v//g'); \
sed "s/docker:\/\/asyncapi\/github-action-for-cli:.*/docker:\/\/asyncapi\/github-action-for-cli:$$version'/g" action.yml > action.yml.tmp
@mv action.yml.tmp action.yml

test: test-default test-validate-success test-validate-fail test-custom-output test-custom-commands test-optimize test-bundle test-convert
test: test-default test-validate-success test-validate-fail test-custom-output test-custom-commands test-optimize test-bundle test-convert test-action-bump

# Test cases

# Tests if the action has been bumped greater than the latest release
# sed "s/docker:\/\/asyncapi\/github-action-for-cli:.*/docker:\/\/asyncapi\/github-action-for-cli:$$version'/g" action.yml > action.yml.tmp
REGEX = docker:\/\/asyncapi\/github-action-for-cli:([0-9.]+)
test-action-bump:
@version=$$(cat package.json | jq -r '.version'); \
action=$$(cat action.yml); \
[[ $$action =~ $(REGEX) ]]; \
action_version=$${BASH_REMATCH[1]}; \
echo "Action version: $$action_version"; \
echo "Package version: $$version"; \
if [[ $$action_version > $$version ]]; then \
echo "Action version is greater than package version"; \
else \
echo "Action version has not been bumped. Please bump the action version to the semantically correct version after $$version"; \
exit 1; \
fi

# Tests the default configuration without any inputs
test-default:
@bash ./entrypoint.sh $(DEFAULT_VERSION) $(DEFAULT_COMMAND) $(TEST_FILEPATH) $(DEFAULT_TEMPLATE) $(DEFAULT_LANGUAGE) $(DEFAULT_OUTPUT) $(DEFAULT_PARAMETERS) $(DEFAULT_CUSTOM_COMMANDS)
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ runs:
using: 'docker'
# This is the image that will be used to run the action.
# IMPORTANT: The version has to be changed manually in your PRs.
image: 'docker://asyncapi/github-action-for-cli:3.0.1'
image: 'docker://asyncapi/github-action-for-cli:3.0.2'
args:
- ${{ inputs.cli_version }}
- ${{ inputs.command }}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"test": "make test",
"generate:assets": "echo 'No additional assets need to be generated at the moment'",
"docker:build": "docker build -t asyncapi/github-action-for-cli:latest .",
"bump:version": "npm --no-git-tag-version --allow-same-version version $VERSION && make generate-assets"
"bump:version": "npm --no-git-tag-version --allow-same-version version $VERSION"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 0753be5

Please sign in to comment.