|
| 1 | +# The MIT License (MIT) |
| 2 | +# |
| 3 | +# Copyright © 2026 The pyTooling Authors |
| 4 | +# |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
| 6 | +# documentation files (the “Software”), to deal in the Software without restriction, including without limitation the |
| 7 | +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit |
| 8 | +# persons to whom the Software is furnished to do so, subject to the following conditions: |
| 9 | +# |
| 10 | +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the |
| 11 | +# Software. |
| 12 | +# |
| 13 | +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
| 14 | +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 15 | +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 16 | +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 17 | +name: Pipeline |
| 18 | +run-name: ${{ github.ref_type == 'tag' && github.ref_name || '' }} |
| 19 | + |
| 20 | +on: |
| 21 | + push: |
| 22 | + # 'TagReleaseCommit' dispatches this workflow on the tag it created; a tag pushed by the automatic GITHUB_TOKEN |
| 23 | + # doesn't trigger a workflow on its own. |
| 24 | + workflow_dispatch: |
| 25 | + |
| 26 | +jobs: |
| 27 | + Prepare: |
| 28 | + uses: pyTooling/Actions/.github/workflows/PrepareJob.yml@r8 |
| 29 | + |
| 30 | + DryRun: |
| 31 | + name: 🐧 Dry-run with a valid configuration |
| 32 | + runs-on: ubuntu-26.04 |
| 33 | + |
| 34 | + steps: |
| 35 | + - name: ⏬ Checkout repository to use the local action |
| 36 | + uses: actions/checkout@v7 |
| 37 | + |
| 38 | + - name: 🔄 Synchronize forked repositories |
| 39 | + id: synchronize |
| 40 | + uses: ./ |
| 41 | + with: |
| 42 | + github-token: ${{ github.token }} |
| 43 | + target-organisation: Paebbels |
| 44 | + directory: tests/Valid |
| 45 | + dry-run: true |
| 46 | + |
| 47 | + - name: 📋 Verify output parameters |
| 48 | + uses: ./.github/actions/check-outputs |
| 49 | + with: |
| 50 | + synchronized: ${{ steps.synchronize.outputs.synchronized }} |
| 51 | + created: ${{ steps.synchronize.outputs.created }} |
| 52 | + created-tags: ${{ steps.synchronize.outputs.created-tags }} |
| 53 | + skipped: ${{ steps.synchronize.outputs.skipped }} |
| 54 | + errors: ${{ steps.synchronize.outputs.errors }} |
| 55 | + # 1 branch of 'ghdl' + 1 branch of 'progit2' + 2 branches of 'itertree' |
| 56 | + expected-synchronized: 4 |
| 57 | + # 1 commented out organisation + 1 commented out repository |
| 58 | + # Dry-run reads no repository, so no branch is created. |
| 59 | + expected-created: 0 |
| 60 | + # Dry-run reads no repository, so no tag is created. |
| 61 | + expected-created-tags: 0 |
| 62 | + expected-skipped: 2 |
| 63 | + expected-errors: 0 |
| 64 | + |
| 65 | + ErrorHandling: |
| 66 | + name: 🐧 Error handling with an invalid configuration |
| 67 | + runs-on: ubuntu-26.04 |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: ⏬ Checkout repository to use the local action |
| 71 | + uses: actions/checkout@v7 |
| 72 | + |
| 73 | + - name: 🔄 Synchronize forked repositories |
| 74 | + id: synchronize |
| 75 | + uses: ./ |
| 76 | + with: |
| 77 | + github-token: ${{ github.token }} |
| 78 | + target-organisation: Paebbels |
| 79 | + directory: tests/Invalid |
| 80 | + dry-run: true |
| 81 | + fail-on-error: false |
| 82 | + |
| 83 | + - name: 📋 Verify output parameters |
| 84 | + uses: ./.github/actions/check-outputs |
| 85 | + with: |
| 86 | + synchronized: ${{ steps.synchronize.outputs.synchronized }} |
| 87 | + created: ${{ steps.synchronize.outputs.created }} |
| 88 | + created-tags: ${{ steps.synchronize.outputs.created-tags }} |
| 89 | + skipped: ${{ steps.synchronize.outputs.skipped }} |
| 90 | + errors: ${{ steps.synchronize.outputs.errors }} |
| 91 | + expected-synchronized: 1 |
| 92 | + expected-created: 0 |
| 93 | + expected-created-tags: 0 |
| 94 | + expected-skipped: 0 |
| 95 | + # 1 missing 'Missing.repos' + 4 malformed lines in 'ghdl.repos' |
| 96 | + expected-errors: 5 |
| 97 | + |
| 98 | + FailOnError: |
| 99 | + name: 🐧 Counted errors let the action fail |
| 100 | + runs-on: ubuntu-26.04 |
| 101 | + |
| 102 | + steps: |
| 103 | + - name: ⏬ Checkout repository to use the local action |
| 104 | + uses: actions/checkout@v7 |
| 105 | + |
| 106 | + - name: 🔄 Synchronize forked repositories |
| 107 | + id: synchronize |
| 108 | + continue-on-error: true |
| 109 | + uses: ./ |
| 110 | + with: |
| 111 | + github-token: ${{ github.token }} |
| 112 | + target-organisation: Paebbels |
| 113 | + directory: tests/Invalid |
| 114 | + dry-run: true |
| 115 | + |
| 116 | + - name: 📋 Verify the action failed |
| 117 | + shell: bash |
| 118 | + env: |
| 119 | + OUTCOME: ${{ steps.synchronize.outcome }} |
| 120 | + run: | |
| 121 | + # 📋 Verify the action failed |
| 122 | + set +e |
| 123 | +
|
| 124 | + ANSI_LIGHT_RED=$'\x1b[91m' |
| 125 | + ANSI_LIGHT_GREEN=$'\x1b[92m' |
| 126 | + ANSI_NOCOLOR=$'\x1b[0m' |
| 127 | +
|
| 128 | + printf "%s" "Checking the action's outcome ... " |
| 129 | + if [[ "${OUTCOME}" == "failure" ]]; then |
| 130 | + printf "%s\n" "${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR} (failure)" |
| 131 | + else |
| 132 | + printf "%s\n" "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR} (expected 'failure', got '${OUTCOME}')" |
| 133 | + printf "::error title=%s::%s\n" "FailOnError" "The action's outcome is '${OUTCOME}', but 'failure' was expected." |
| 134 | + exit 1 |
| 135 | + fi |
| 136 | +
|
| 137 | + # A merge commit on 'main' is a release: tag it with the release pull-request's title and start this pipeline again |
| 138 | + # on that tag. |
| 139 | + TriggerTaggedRelease: |
| 140 | + uses: pyTooling/Actions/.github/workflows/TagReleaseCommit.yml@r8 |
| 141 | + needs: |
| 142 | + - Prepare |
| 143 | + - DryRun |
| 144 | + - ErrorHandling |
| 145 | + - FailOnError |
| 146 | + if: needs.Prepare.outputs.is_release_commit == 'true' |
| 147 | + permissions: |
| 148 | + contents: write # required to create the tag |
| 149 | + actions: write # required to start the tagged pipeline |
| 150 | + with: |
| 151 | + version: ${{ needs.Prepare.outputs.version }} |
| 152 | + auto_tag: ${{ needs.Prepare.outputs.is_release_commit }} |
| 153 | + secrets: inherit |
| 154 | + |
| 155 | + # In parallel to the release page: propose the version branch update, so consumers pinning '@v1' can be moved to |
| 156 | + # this release by merging one pull-request. The workflow is local for now; once it has proven itself here it can be |
| 157 | + # promoted to pyTooling/Actions. |
| 158 | + UpdateVersionBranch: |
| 159 | + uses: ./.github/workflows/UpdateVersionBranch.yml |
| 160 | + needs: |
| 161 | + - Prepare |
| 162 | + - DryRun |
| 163 | + - ErrorHandling |
| 164 | + - FailOnError |
| 165 | + if: needs.Prepare.outputs.is_release_tag == 'true' |
| 166 | + permissions: |
| 167 | + contents: write # required to create a version branch |
| 168 | + pull-requests: write # required to open the pull-request |
| 169 | + with: |
| 170 | + version: ${{ needs.Prepare.outputs.version }} |
| 171 | + prefix: 'v' |
| 172 | + |
| 173 | + # The tagged run publishes the release page. Its description is the body of the pull-request that produced the |
| 174 | + # tagged merge commit, which 'PublishReleaseNotes' looks up itself. |
| 175 | + ReleasePage: |
| 176 | + uses: pyTooling/Actions/.github/workflows/PublishReleaseNotes.yml@r8 |
| 177 | + needs: |
| 178 | + - Prepare |
| 179 | + - DryRun |
| 180 | + - ErrorHandling |
| 181 | + - FailOnError |
| 182 | + if: needs.Prepare.outputs.is_release_tag == 'true' |
| 183 | + with: |
| 184 | + tag: ${{ needs.Prepare.outputs.version }} |
| 185 | + secrets: inherit |
0 commit comments