Dirty tests with_v false #157
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
# This workflow tests the tag action and can be used on PRs to detect (some) breaking changes. | |
on: | |
workflow_dispatch: | |
pull_request: | |
types: | |
- opened | |
- edited | |
- reopened | |
- synchronize | |
permissions: | |
pull-requests: write | |
checks: write | |
contents: read | |
jobs: | |
test-action: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: '0' | |
# Use the action to generate a tag for itself | |
- name: Test action main1 (with_v true) | |
id: test_main1 | |
uses: ./ | |
env: | |
DRY_RUN: true | |
WITH_V: true | |
VERBOSE: true | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Test action main2 (with_v false) | |
id: test_main2 | |
uses: ./ | |
env: | |
DRY_RUN: true | |
WITH_V: false | |
VERBOSE: true | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Use the action to generate a tag for itself | |
- name: Test action pre1-release (with_v) | |
id: test_pre1 | |
uses: ./ | |
env: | |
DRY_RUN: true | |
WITH_V: true | |
PRERELEASE: true | |
PRERELEASE_SUFFIX: test | |
VERBOSE: true | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Test action pre2-release (with_v false) | |
id: test_pre2 | |
uses: ./ | |
env: | |
DRY_RUN: true | |
WITH_V: false | |
PRERELEASE: 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: | | |
set -x | |
MAIN1_OUTPUT_TAG=${{ steps.test_main1.outputs.old_tag }} | |
MAIN1_OUTPUT_NEWTAG=${{ steps.test_main1.outputs.new_tag }} | |
MAIN1_OUTPUT_PART=${{ steps.test_main1.outputs.part }} | |
PRE1_OUTPUT_TAG=${{ steps.test_pre1.outputs.old_tag }} | |
PRE1_OUTPUT_NEWTAG=${{ steps.test_pre1.outputs.new_tag }} | |
PRE1_OUTPUT_PART=${{ steps.test_pre1.outputs.part }} | |
echo "Outputs from running the action:" >> $GITHUB_STEP_SUMMARY | |
echo "MAIN1 Tag: $MAIN1_OUTPUT_TAG" >> $GITHUB_STEP_SUMMARY | |
echo "MAIN1 New tag: $MAIN1_OUTPUT_NEWTAG" >> $GITHUB_STEP_SUMMARY | |
echo "MAIN1 Part: $MAIN1_OUTPUT_PART" >> $GITHUB_STEP_SUMMARY | |
echo "PRE1 Tag: $PRE1_OUTPUT_TAG" >> $GITHUB_STEP_SUMMARY | |
echo "PRE1 New tag: $PRE1_OUTPUT_NEWTAG" >> $GITHUB_STEP_SUMMARY | |
echo "PRE1 Part: $PRE1_OUTPUT_PART" >> $GITHUB_STEP_SUMMARY | |
MAIN2_OUTPUT_TAG=${{ steps.test_main2.outputs.old_tag }} | |
MAIN2_OUTPUT_NEWTAG=${{ steps.test_main2.outputs.new_tag }} | |
MAIN2_OUTPUT_PART=${{ steps.test_main2.outputs.part }} | |
PRE2_OUTPUT_TAG=${{ steps.test_pre2.outputs.old_tag }} | |
PRE2_OUTPUT_NEWTAG=${{ steps.test_pre2.outputs.new_tag }} | |
PRE2_OUTPUT_PART=${{ steps.test_pre2.outputs.part }} | |
echo "Outputs from running the action:" >> $GITHUB_STEP_SUMMARY | |
echo "MAIN2 Tag: $MAIN2_OUTPUT_TAG" >> $GITHUB_STEP_SUMMARY | |
echo "MAIN2 New tag: $MAIN2_OUTPUT_NEWTAG" >> $GITHUB_STEP_SUMMARY | |
echo "MAIN2 Part: $MAIN2_OUTPUT_PART" >> $GITHUB_STEP_SUMMARY | |
echo "PRE2 Tag: $PRE2_OUTPUT_TAG" >> $GITHUB_STEP_SUMMARY | |
echo "PRE2 New tag: $PRE2_OUTPUT_NEWTAG" >> $GITHUB_STEP_SUMMARY | |
echo "PRE2 Part: $PRE2_OUTPUT_PART" >> $GITHUB_STEP_SUMMARY | |
# check that the original tag got bumped either major, minor, patch | |
verlte() { | |
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ] | |
} | |
verlt() { | |
[ "$1" = "$2" ] && return 1 || verlte $1 $2 | |
} | |
main1="$(verlt $MAIN1_OUTPUT_TAG $MAIN1_OUTPUT_NEWTAG && true || false)" | |
pre1="$(verlt $PRE1_OUTPUT_TAG $PRE1_OUTPUT_NEWTAG && true || false)" | |
main2="$(verlt $MAIN2_OUTPUT_TAG $MAIN2_OUTPUT_NEWTAG && true || false)" | |
pre2="$(verlt $PRE2_OUTPUT_TAG $PRE2_OUTPUT_NEWTAG && true || false)" | |
if $main1 && $pre1 && $main2 && $pre2 | |
then | |
echo "The tags were created correctly" >> $GITHUB_STEP_SUMMARY | |
else | |
echo "Tags not created correctly" >> $GITHUB_STEP_SUMMARY | |
exit 1 | |
fi | |
# todo add test for #none bump | |