|
| 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: Verification of the Synchronize Forks Action |
| 18 | + |
| 19 | +on: |
| 20 | + push: |
| 21 | + workflow_dispatch: |
| 22 | + |
| 23 | +jobs: |
| 24 | + DryRun: |
| 25 | + name: 🐧 Dry-run with a valid configuration |
| 26 | + runs-on: ubuntu-26.04 |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: ⏬ Checkout repository to use the local action |
| 30 | + uses: actions/checkout@v7 |
| 31 | + |
| 32 | + - name: 🔄 Synchronize forked repositories |
| 33 | + id: synchronize |
| 34 | + uses: ./ |
| 35 | + with: |
| 36 | + github-token: ${{ github.token }} |
| 37 | + target-organisation: Paebbels |
| 38 | + directory: tests/Valid |
| 39 | + dry-run: true |
| 40 | + |
| 41 | + - name: 📋 Verify output parameters |
| 42 | + uses: ./.github/actions/check-outputs |
| 43 | + with: |
| 44 | + synchronized: ${{ steps.synchronize.outputs.synchronized }} |
| 45 | + skipped: ${{ steps.synchronize.outputs.skipped }} |
| 46 | + errors: ${{ steps.synchronize.outputs.errors }} |
| 47 | + # 1 branch of 'ghdl' + 1 branch of 'progit2' + 2 branches of 'itertree' |
| 48 | + expected-synchronized: 4 |
| 49 | + # 1 commented out organisation + 1 commented out repository |
| 50 | + expected-skipped: 2 |
| 51 | + expected-errors: 0 |
| 52 | + |
| 53 | + ErrorHandling: |
| 54 | + name: 🐧 Error handling with an invalid configuration |
| 55 | + runs-on: ubuntu-26.04 |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: ⏬ Checkout repository to use the local action |
| 59 | + uses: actions/checkout@v7 |
| 60 | + |
| 61 | + - name: 🔄 Synchronize forked repositories |
| 62 | + id: synchronize |
| 63 | + uses: ./ |
| 64 | + with: |
| 65 | + github-token: ${{ github.token }} |
| 66 | + target-organisation: Paebbels |
| 67 | + directory: tests/Invalid |
| 68 | + dry-run: true |
| 69 | + fail-on-error: false |
| 70 | + |
| 71 | + - name: 📋 Verify output parameters |
| 72 | + uses: ./.github/actions/check-outputs |
| 73 | + with: |
| 74 | + synchronized: ${{ steps.synchronize.outputs.synchronized }} |
| 75 | + skipped: ${{ steps.synchronize.outputs.skipped }} |
| 76 | + errors: ${{ steps.synchronize.outputs.errors }} |
| 77 | + expected-synchronized: 1 |
| 78 | + expected-skipped: 0 |
| 79 | + # 1 missing 'Missing.repos' + 2 malformed lines in 'ghdl.repos' |
| 80 | + expected-errors: 3 |
| 81 | + |
| 82 | + FailOnError: |
| 83 | + name: 🐧 Counted errors let the action fail |
| 84 | + runs-on: ubuntu-26.04 |
| 85 | + |
| 86 | + steps: |
| 87 | + - name: ⏬ Checkout repository to use the local action |
| 88 | + uses: actions/checkout@v7 |
| 89 | + |
| 90 | + - name: 🔄 Synchronize forked repositories |
| 91 | + id: synchronize |
| 92 | + continue-on-error: true |
| 93 | + uses: ./ |
| 94 | + with: |
| 95 | + github-token: ${{ github.token }} |
| 96 | + target-organisation: Paebbels |
| 97 | + directory: tests/Invalid |
| 98 | + dry-run: true |
| 99 | + |
| 100 | + - name: 📋 Verify the action failed |
| 101 | + shell: bash |
| 102 | + env: |
| 103 | + OUTCOME: ${{ steps.synchronize.outcome }} |
| 104 | + run: | |
| 105 | + # 📋 Verify the action failed |
| 106 | + set +e |
| 107 | +
|
| 108 | + ANSI_LIGHT_RED=$'\x1b[91m' |
| 109 | + ANSI_LIGHT_GREEN=$'\x1b[92m' |
| 110 | + ANSI_NOCOLOR=$'\x1b[0m' |
| 111 | +
|
| 112 | + printf "%s" "Checking the action's outcome ... " |
| 113 | + if [[ "${OUTCOME}" == "failure" ]]; then |
| 114 | + printf "%s\n" "${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR} (failure)" |
| 115 | + else |
| 116 | + printf "%s\n" "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR} (expected 'failure', got '${OUTCOME}')" |
| 117 | + printf "::error title=%s::%s\n" "FailOnError" "The action's outcome is '${OUTCOME}', but 'failure' was expected." |
| 118 | + exit 1 |
| 119 | + fi |
0 commit comments