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

Add basic test of Action #176

Merged
merged 7 commits into from Sep 12, 2022
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,69 @@
name: Test
# This workflow tests the tag action and can be used on PRs to detect (some) breaking changes.

on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
push:
branches:
- master
workflow_dispatch:

jobs:
test-action:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: '0'

# Use the action to generate a tag for itself
- name: Test action
id: test
uses: ./
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this I did not know was possible 🤩

env:
DRY_RUN: true
WITH_V: true
PRERELEASE_SUFFIX: test
VERBOSE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Check if the action created the expected output
- name: Check if the tag would have been created
shell: bash
run: |
sammcj marked this conversation as resolved.
Show resolved Hide resolved
sammcj marked this conversation as resolved.
Show resolved Hide resolved
sammcj marked this conversation as resolved.
Show resolved Hide resolved
sammcj marked this conversation as resolved.
Show resolved Hide resolved
sammcj marked this conversation as resolved.
Show resolved Hide resolved
sammcj marked this conversation as resolved.
Show resolved Hide resolved
sammcj marked this conversation as resolved.
Show resolved Hide resolved
sammcj marked this conversation as resolved.
Show resolved Hide resolved
sammcj marked this conversation as resolved.
Show resolved Hide resolved
sammcj marked this conversation as resolved.
Show resolved Hide resolved
sammcj marked this conversation as resolved.
Show resolved Hide resolved
sammcj marked this conversation as resolved.
Show resolved Hide resolved
sammcj marked this conversation as resolved.
Show resolved Hide resolved
OUTPUT_TAG=${{ steps.test.outputs.tag }}
OUTPUT_NEWTAG=${{ steps.test.outputs.new_tag }}
OUTPUT_PART=${{ steps.test.outputs.part }}

echo "Outputs from running the action:"
echo "Tag: $OUTPUT_TAG"
echo "New tag: $OUTPUT_NEWTAG"
echo "Part: $OUTPUT_PART"

# Work out what the new tag should be
a=( ${OUTPUT_TAG//./ } )
((a[1]++))
a[2]=0
CORRECT_TAG="${a[0]}.${a[1]}.${a[2]}-test.0"

if [[ $OUTPUT_NEWTAG == $CORRECT_TAG ]]; then
echo "The tag was created correctly"
else
echo "The tag was not created correctly, expected $CORRECT_TAG got $OUTPUT_NEWTAG"
exit 1
fi

if $OUTPUT_NEWTAG ; then
echo "The tag was created as expected"
exit 0
else
echo "The action did not create a new tag"
exit 1
fi