|
16 | 16 | VERBOSE: ${{ github.event.inputs.verbose }}
|
17 | 17 |
|
18 | 18 | jobs:
|
19 |
| - check-labels: |
| 19 | + apply-label-to-new-pr: |
20 | 20 | runs-on: ubuntu-latest
|
21 | 21 | if: ${{ github.event.pull_request.draft == false }}
|
22 | 22 | outputs:
|
23 |
| - run-cli-tests: ${{ contains(github.event.pull_request.labels.*.name, 'run-bittensor-cli-tests') }} |
| 23 | + should_continue: ${{ steps.check.outputs.should_continue }} |
| 24 | + steps: |
| 25 | + - name: Check |
| 26 | + id: check |
| 27 | + run: | |
| 28 | + ACTION="${{ github.event.action }}" |
| 29 | + if [[ "$ACTION" == "opened" || "$ACTION" == "reopened" ]]; then |
| 30 | + echo "should_continue=true" >> $GITHUB_ENV; |
| 31 | + echo "::set-output name=should_continue::true"; |
| 32 | + else |
| 33 | + echo "should_continue=false" >> $GITHUB_ENV; |
| 34 | + echo "::set-output name=should_continue::false"; |
| 35 | + fi |
| 36 | + shell: bash |
| 37 | + |
| 38 | + - name: Add label |
| 39 | + if: steps.check.outputs.should_continue == 'true' |
| 40 | + uses: actions-ecosystem/action-add-labels@v1 |
| 41 | + with: |
| 42 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + labels: run-bittensor-cli-tests |
| 44 | + |
| 45 | + check-labels: |
| 46 | + needs: apply-label-to-new-pr |
| 47 | + runs-on: ubuntu-latest |
| 48 | + if: always() |
| 49 | + outputs: |
| 50 | + run-cli-tests: ${{ steps.get-labels.outputs.run-cli-tests }} |
24 | 51 | steps:
|
25 | 52 | - name: Check out repository
|
26 | 53 | uses: actions/checkout@v4
|
27 | 54 |
|
| 55 | + - name: Get labels from PR |
| 56 | + id: get-labels |
| 57 | + run: | |
| 58 | + LABELS=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') |
| 59 | + echo "Current labels: $LABELS" |
| 60 | + if echo "$LABELS" | grep -q "run-bittensor-cli-tests"; then |
| 61 | + echo "run-cli-tests=true" >> $GITHUB_ENV |
| 62 | + echo "::set-output name=run-cli-tests::true" |
| 63 | + else |
| 64 | + echo "run-cli-tests=false" >> $GITHUB_ENV |
| 65 | + echo "::set-output name=run-cli-tests::false" |
| 66 | + fi |
| 67 | + env: |
| 68 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + |
28 | 70 | find-e2e-tests:
|
29 | 71 | needs: check-labels
|
30 |
| - if: needs.check-labels.outputs.run-cli-tests == 'true' |
| 72 | + if: always() && needs.check-labels.outputs.run-cli-tests == 'true' |
31 | 73 | runs-on: ubuntu-latest
|
32 | 74 | outputs:
|
33 | 75 | test-files: ${{ steps.get-tests.outputs.test-files }}
|
|
53 | 95 | pull-docker-image:
|
54 | 96 | needs: check-labels
|
55 | 97 | runs-on: ubuntu-latest
|
56 |
| - if: needs.check-labels.outputs.run-cli-tests == 'true' |
| 98 | + if: always() && needs.check-labels.outputs.run-cli-tests == 'true' |
57 | 99 | steps:
|
58 | 100 | - name: Log in to GitHub Container Registry
|
59 | 101 | run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
|
|
76 | 118 | - find-e2e-tests
|
77 | 119 | - pull-docker-image
|
78 | 120 |
|
79 |
| - if: needs.check-labels.outputs.run-cli-tests == 'true' |
| 121 | + if: always() && needs.check-labels.outputs.run-cli-tests == 'true' |
80 | 122 | runs-on: ubuntu-latest
|
81 | 123 | strategy:
|
82 | 124 | fail-fast: false
|
@@ -178,7 +220,7 @@ jobs:
|
178 | 220 | run-unit-test:
|
179 | 221 | needs:
|
180 | 222 | - check-labels
|
181 |
| - if: needs.check-labels.outputs.run-cli-tests == 'true' |
| 223 | + if: always() && needs.check-labels.outputs.run-cli-tests == 'true' |
182 | 224 | runs-on: ubuntu-latest
|
183 | 225 | steps:
|
184 | 226 | - name: Check-out repository
|
|
0 commit comments