Skip to content

Revert "Merge pull request #313 from anothrNick/revert-310-master" #242

Revert "Merge pull request #313 from anothrNick/revert-310-master"

Revert "Merge pull request #313 from anothrNick/revert-310-master" #242

Workflow file for this run

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@v4
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
DEFAULT_BUMP: minor # default
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
DEFAULT_BUMP: major
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test action main3 (with_v false)
id: test_main3
uses: ./
env:
DRY_RUN: true
WITH_V: false
VERBOSE: true
DEFAULT_BUMP: none
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test action main4 (with_v true)
id: test_main4
uses: ./
env:
DRY_RUN: true
WITH_V: true
VERBOSE: true
DEFAULT_BUMP: none
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test action main5 (with_v true)
id: test_main5
uses: ./
env:
DRY_RUN: true
WITH_V: true
VERBOSE: true
DEFAULT_BUMP: patch
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Use the action to generate a tag for itself
- name: Test action pre1-release (with_v true)
id: test_pre1
uses: ./
env:
DRY_RUN: true
WITH_V: true
PRERELEASE: true
PRERELEASE_SUFFIX: test
VERBOSE: true
DEFAULT_BUMP: minor # default
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
DEFAULT_BUMP: major
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 }}
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 }}
MAIN3_OUTPUT_TAG=${{ steps.test_main3.outputs.old_tag }}
MAIN3_OUTPUT_NEWTAG=${{ steps.test_main3.outputs.new_tag }}
MAIN3_OUTPUT_PART=${{ steps.test_main3.outputs.part }}
MAIN4_OUTPUT_TAG=${{ steps.test_main4.outputs.old_tag }}
MAIN4_OUTPUT_NEWTAG=${{ steps.test_main4.outputs.new_tag }}
MAIN4_OUTPUT_PART=${{ steps.test_main4.outputs.part }}
MAIN5_OUTPUT_TAG=${{ steps.test_main5.outputs.old_tag }}
MAIN5_OUTPUT_NEWTAG=${{ steps.test_main5.outputs.new_tag }}
MAIN5_OUTPUT_PART=${{ steps.test_main5.outputs.part }}
echo -e "> MAIN tests with_v, default bump:\n" >> $GITHUB_STEP_SUMMARY
echo "MAIN1 with_v Tag: $MAIN1_OUTPUT_TAG" >> $GITHUB_STEP_SUMMARY
echo "MAIN1 with_v New tag: $MAIN1_OUTPUT_NEWTAG" >> $GITHUB_STEP_SUMMARY
echo "MAIN1 with_v Part: $MAIN1_OUTPUT_PART" >> $GITHUB_STEP_SUMMARY
echo -e "> Pre-release tests with_v, default bump:\n" >> $GITHUB_STEP_SUMMARY
echo "PRE1 with_v Tag: $PRE1_OUTPUT_TAG" >> $GITHUB_STEP_SUMMARY
echo "PRE1 with_v New tag: $PRE1_OUTPUT_NEWTAG" >> $GITHUB_STEP_SUMMARY
echo "PRE1 with_v Part: $PRE1_OUTPUT_PART" >> $GITHUB_STEP_SUMMARY
echo -e "> MAIN tests without_v, bump major:\n" >> $GITHUB_STEP_SUMMARY
echo "MAIN2 without_v Tag: $MAIN2_OUTPUT_TAG" >> $GITHUB_STEP_SUMMARY
echo "MAIN2 without_v New tag: $MAIN2_OUTPUT_NEWTAG" >> $GITHUB_STEP_SUMMARY
echo "MAIN2 without_v Part: $MAIN2_OUTPUT_PART" >> $GITHUB_STEP_SUMMARY
echo -e "> Pre-release tests without_v, bump major:\n" >> $GITHUB_STEP_SUMMARY
echo "PRE2 without_v Tag: $PRE2_OUTPUT_TAG" >> $GITHUB_STEP_SUMMARY
echo "PRE2 without_v New tag: $PRE2_OUTPUT_NEWTAG" >> $GITHUB_STEP_SUMMARY
echo "PRE2 without_v Part: $PRE2_OUTPUT_PART" >> $GITHUB_STEP_SUMMARY
echo -e "> MAIN tests without_v, bump none: (should be the same old tag no change regardless of what original tag contains or not v)\n" >> $GITHUB_STEP_SUMMARY
echo "MAIN3 without_v Tag: $MAIN3_OUTPUT_TAG" >> $GITHUB_STEP_SUMMARY
echo "MAIN3 without_v New tag: $MAIN3_OUTPUT_NEWTAG" >> $GITHUB_STEP_SUMMARY
echo "MAIN3 without_v Part: $MAIN3_OUTPUT_PART" >> $GITHUB_STEP_SUMMARY
echo -e "> MAIN tests with_v, bump none: (should be the same old tag no change regardless of what original tag contains or not v)\n" >> $GITHUB_STEP_SUMMARY
echo "MAIN4 with_v Tag: $MAIN4_OUTPUT_TAG" >> $GITHUB_STEP_SUMMARY
echo "MAIN4 with_v New tag: $MAIN4_OUTPUT_NEWTAG" >> $GITHUB_STEP_SUMMARY
echo "MAIN4 with_v Part: $MAIN4_OUTPUT_PART" >> $GITHUB_STEP_SUMMARY
echo -e "> MAIN tests with_v, bump patch:\n" >> $GITHUB_STEP_SUMMARY
echo "MAIN5 with_v Tag: $MAIN5_OUTPUT_TAG" >> $GITHUB_STEP_SUMMARY
echo "MAIN5 with_v New tag: $MAIN5_OUTPUT_NEWTAG" >> $GITHUB_STEP_SUMMARY
echo "MAIN5 with_v Part: $MAIN5_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
}
# needs to be a greater tag in default minor
main1="$(verlt $MAIN1_OUTPUT_TAG $MAIN1_OUTPUT_NEWTAG && true || false)"
pre1="$(verlt $PRE1_OUTPUT_TAG $PRE1_OUTPUT_NEWTAG && true || false)"
# needs to be a greater tag in bump major
main2="$(verlt $MAIN2_OUTPUT_TAG $MAIN2_OUTPUT_NEWTAG && true || false)"
pre2="$(verlt $PRE2_OUTPUT_TAG $PRE2_OUTPUT_NEWTAG && true || false)"
# needs to be the latest tag of the repo when bump is none
main3="$([ "$MAIN3_OUTPUT_TAG" = "$MAIN3_OUTPUT_NEWTAG" ] && true || false)"
main4="$([ "$MAIN4_OUTPUT_TAG" = "$MAIN4_OUTPUT_NEWTAG" ] && true || false)"
# needs to be a greater tag in bump patch
main5="$(verlt $MAIN5_OUTPUT_TAG $MAIN5_OUTPUT_NEWTAG && true || false)"
if $main1 && $pre1 && $main2 && $pre2 && $main3 && $main4 && $main5
then
echo -e "\n>>>>The tags were created correctly" >> $GITHUB_STEP_SUMMARY
else
echo -e "\n>>>>Tags NOT created correctly" >> $GITHUB_STEP_SUMMARY
exit 1
fi