Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix #67

Merged
merged 8 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 45 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,55 @@ jobs:
- name: Checkout code
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

- name: Run dev
id: tag_dev
- name: Run dev with error cases (should fail)
run: |
echo "Testing with no GITHUB_REF set"
GITHUB_REF="" node main.js
# shellcheck disable=SC2181
if [ $? -ne 1 ]; then echo "Expected failure on no GITHUB_REF set"; fi

- name: Run dev with error cases (should fail)
if: always()
run: |
echo "Testing with invalid GITHUB_REF"
GITHUB_REF=origin/refs/tag/v1 node main.js
# shellcheck disable=SC2181
if [ $? -ne 1 ]; then echo "Expected failure on invalid ref"; fi

- name: Run dev with different error cases (should fail)
if: always()
run: |
echo "Testing with valid GITHUB_REF"
GITHUB_REF=refs/tag/v1 node main.js
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then echo "Not expected a failure on valid ref to tag"; fi

- name: Run dev
id: tag_dev
run: |
echo "Testing with valid GITHUB_REF"
GITHUB_REF=refs/heads/main node main.js
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then echo "Not expected a failure on valid ref to branch"; fi

echo "Testing with valid GITHUB_REF"
GITHUB_REF=refs/tags/v1.0.0 node main.js
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then echo "Not expected a failure on valid ref with minor version"; fi

- name: Test dev
if: always()
run: |
test "v1.0.0" = "${{steps.tag_dev.outputs.tag}}"

- name: Run dev with strip v
if: always()
id: tag_dev_strip_v
run: |
GITHUB_REF=refs/tags/v1.0.0 INPUT_STRIP_V=true node main.js
GITHUB_REF=refs/tags/v1.0.0 INPUT_STRIP_V="true" node main.js

- name: Test dev with strip v
if: always()
run: |
test "1.0.0" = "${{steps.tag_dev_strip_v.outputs.tag}}"

Expand All @@ -62,3 +78,29 @@ jobs:
if: startsWith(github.ref, 'refs/tags') == true
run: |
test -n "${{steps.tag_prod.outputs.tag}}"


- name: Run dev with no strip_v and a default
if: always()
id: tag_dev_no_strip_v_default
run: |
GITHUB_REF=refs/tags/v1.0.0 INPUT_STRIP_V="false" INPUT_DEFAULT="v0.0.0" node main.js

- name: Test dev with no strip_v and default value
if: always()
run: |
test "v1.0.0" = "${{steps.tag_dev_no_strip_v_default.outputs.tag}}"


- name: Run dev with no tag, no strip_v and a default and not a tag
if: always()
id: no_tag_dev_no_strip_v_default
run: |
GITHUB_REF=random_branch INPUT_STRIP_V="false" INPUT_DEFAULT="v0.99.0" node main.js

- name: Test dev with no tag, no strip_v and default value
if: always()
run: |
test "v0.99.0" = "${{steps.no_tag_dev_no_strip_v_default.outputs.tag}}"


2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
```yaml
- name: Get tag
id: tag
uses: devops-actions/[email protected].1
uses: devops-actions/[email protected].2
with:
strip_v: true # Optional: Remove 'v' character from version
default: v0.0.0 # Optional: Default version when tag not found
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ branding:
inputs:
strip_v:
required: false
default: false
default: "false"
description: Whether to strip "v" from the tag or not (optional)
default:
required: false
Expand Down
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function main() {
throw `Not a tag ref (${ref}) or default version not set`

if(!tag)
throw `Not tag version found`
throw `No tag version found`

if(strip_v === "true" && tag.startsWith("v"))
tag = tag.replace(/^v/, "")
Expand Down
6 changes: 3 additions & 3 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions node_modules/@actions/core/lib/core.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@actions/core/lib/oidc-utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@actions/core/lib/oidc-utils.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions node_modules/@actions/core/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading