From a0c521bd9c733a2854dd10c07b1a3a77c3c8ebf7 Mon Sep 17 00:00:00 2001 From: Sam McLeod Date: Mon, 12 Sep 2022 14:30:03 +1000 Subject: [PATCH 1/7] Add basic test of Action --- .github/workflows/test.yml | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..bf008155 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,51 @@ +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: ./ + env: + DRY_RUN: true + WITH_V: true + INITIAL_VERSION: 'v100.0.0' # For testing purposes only + VERBOSE: true + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Check if the action created the expected output + - name: Check if the tag would have been created + run: | + echo "Outputs from running the action:" + echo "TAG = ${{ steps.test.outputs.tag }}" + echo "NEW TAG = ${{ steps.test.outputs.new_tag }}" + echo "PART = ${{ steps.test.outputs.part }}" + + if ${{ steps.test.outputs.new_tag == 'v100.0.1' }}; then + echo "The tag was created as expected" + exit 0 + else + echo "The action did not create a new tag" + exit 1 + fi + From 14a4d163bf49eabad30bc138d81aae45539bc5c4 Mon Sep 17 00:00:00 2001 From: Sam McLeod Date: Mon, 12 Sep 2022 15:00:18 +1000 Subject: [PATCH 2/7] Add basic test of Action --- .github/workflows/test.yml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bf008155..9d15ddb8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,19 +29,36 @@ jobs: env: DRY_RUN: true WITH_V: true - INITIAL_VERSION: 'v100.0.0' # For testing purposes only + 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 run: | + 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 = ${{ steps.test.outputs.tag }}" - echo "NEW TAG = ${{ steps.test.outputs.new_tag }}" - echo "PART = ${{ steps.test.outputs.part }}" + echo "Tag: $OUTPUT_TAG" + echo "New tag: $OUTPUT_NEWTAG" + echo "Part: $OUTPUT_PART" + + # Work out what the new tag should be + INCREMENT=$(echo $TAG | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}') + CORRECT_TAG="$INCREMENT-test.0" + + # Bash if statement that checks that the OUTPUT_NEWTAG value is the same as the + # OUTPUT_TAG action but one number higher and with a suffix of -test.* + 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 ${{ steps.test.outputs.new_tag == 'v100.0.1' }}; then + if $OUTPUT_NEWTAG ; then echo "The tag was created as expected" exit 0 else From 3b56c0fb780859e665f6a96f29837617cee67dda Mon Sep 17 00:00:00 2001 From: Sam McLeod Date: Mon, 12 Sep 2022 15:09:56 +1000 Subject: [PATCH 3/7] Add basic test of Action --- .github/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9d15ddb8..5f3b2efb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,10 +35,11 @@ jobs: # Check if the action created the expected output - name: Check if the tag would have been created + shell: bash run: | - OUTPUT_TAG = ${{ steps.test.outputs.tag }} - OUTPUT_NEWTAG = ${{ steps.test.outputs.new_tag }} - OUTPUT_PART = ${{ steps.test.outputs.part }} + 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" From cd40522754cdc2486ba217dfbbf06f52c2a43744 Mon Sep 17 00:00:00 2001 From: Sam McLeod Date: Mon, 12 Sep 2022 15:11:39 +1000 Subject: [PATCH 4/7] Add basic test of Action --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5f3b2efb..451b538e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,7 +47,7 @@ jobs: echo "Part: $OUTPUT_PART" # Work out what the new tag should be - INCREMENT=$(echo $TAG | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}') + INCREMENT=$(echo $OUTPUT_TAG | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}') CORRECT_TAG="$INCREMENT-test.0" # Bash if statement that checks that the OUTPUT_NEWTAG value is the same as the From d01692e01716381ae9764ef375e7370a2316e5e1 Mon Sep 17 00:00:00 2001 From: Sam McLeod Date: Mon, 12 Sep 2022 15:24:01 +1000 Subject: [PATCH 5/7] Add basic test of Action --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 451b538e..8e2ddb15 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,11 +47,11 @@ jobs: echo "Part: $OUTPUT_PART" # Work out what the new tag should be - INCREMENT=$(echo $OUTPUT_TAG | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}') - CORRECT_TAG="$INCREMENT-test.0" + a=( ${OUTPUT_TAG//./ } ) + ((a[1]++)) + a[2]=0 + CORRECT_TAG="${a[0]}.${a[1]}.${a[2]}-test.0" - # Bash if statement that checks that the OUTPUT_NEWTAG value is the same as the - # OUTPUT_TAG action but one number higher and with a suffix of -test.* if [[ $OUTPUT_NEWTAG == $CORRECT_TAG ]]; then echo "The tag was created correctly" else From da47ac147bbd31aa36a0c7f37f308e6f5392ae30 Mon Sep 17 00:00:00 2001 From: Sam McLeod Date: Mon, 12 Sep 2022 15:26:21 +1000 Subject: [PATCH 6/7] Add basic test of Action --- .github/workflows/test.yml | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e2ddb15..6564608c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,29 +41,21 @@ jobs: 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" + echo "Outputs from running the action:" >> $GITHUB_SUMMARY + echo "Tag: $OUTPUT_TAG" >> $GITHUB_SUMMARY + echo "New tag: $OUTPUT_NEWTAG" >> $GITHUB_SUMMARY + echo "Part: $OUTPUT_PART" >> $GITHUB_SUMMARY # 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" + CORRECT_TAG="v${a[0]}.${a[1]}.${a[2]}-test.0" if [[ $OUTPUT_NEWTAG == $CORRECT_TAG ]]; then - echo "The tag was created correctly" + echo "The tag was created correctly" >> $GITHUB_SUMMARY 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" + echo "The tag was not created correctly, expected $CORRECT_TAG got $OUTPUT_NEWTAG" >> $GITHUB_SUMMARY exit 1 fi From febc39f8f5d51798ea21dcd643e4f4ef9f5af88b Mon Sep 17 00:00:00 2001 From: Sam McLeod Date: Mon, 12 Sep 2022 15:28:17 +1000 Subject: [PATCH 7/7] Add basic test of Action --- .github/workflows/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6564608c..d744dc79 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,10 +41,10 @@ jobs: OUTPUT_NEWTAG=${{ steps.test.outputs.new_tag }} OUTPUT_PART=${{ steps.test.outputs.part }} - echo "Outputs from running the action:" >> $GITHUB_SUMMARY - echo "Tag: $OUTPUT_TAG" >> $GITHUB_SUMMARY - echo "New tag: $OUTPUT_NEWTAG" >> $GITHUB_SUMMARY - echo "Part: $OUTPUT_PART" >> $GITHUB_SUMMARY + echo "Outputs from running the action:" >> $GITHUB_STEP_SUMMARY + echo "Tag: $OUTPUT_TAG" >> $GITHUB_STEP_SUMMARY + echo "New tag: $OUTPUT_NEWTAG" >> $GITHUB_STEP_SUMMARY + echo "Part: $OUTPUT_PART" >> $GITHUB_STEP_SUMMARY # Work out what the new tag should be a=( ${OUTPUT_TAG//./ } ) @@ -53,9 +53,9 @@ jobs: CORRECT_TAG="v${a[0]}.${a[1]}.${a[2]}-test.0" if [[ $OUTPUT_NEWTAG == $CORRECT_TAG ]]; then - echo "The tag was created correctly" >> $GITHUB_SUMMARY + echo "The tag was created correctly" >> $GITHUB_STEP_SUMMARY else - echo "The tag was not created correctly, expected $CORRECT_TAG got $OUTPUT_NEWTAG" >> $GITHUB_SUMMARY + echo "The tag was not created correctly, expected $CORRECT_TAG got $OUTPUT_NEWTAG" >> $GITHUB_STEP_SUMMARY exit 1 fi