Skip to content

Commit ac93761

Browse files
committed
check-labels
1 parent d9af11a commit ac93761

File tree

2 files changed

+48
-16
lines changed

2 files changed

+48
-16
lines changed

.github/workflows/check-btcli-tests.yml

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,60 @@ env:
1616
VERBOSE: ${{ github.event.inputs.verbose }}
1717

1818
jobs:
19-
check-labels:
19+
apply-label-to-new-pr:
2020
runs-on: ubuntu-latest
2121
if: ${{ github.event.pull_request.draft == false }}
2222
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 }}
2451
steps:
2552
- name: Check out repository
2653
uses: actions/checkout@v4
2754

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+
2870
find-e2e-tests:
2971
needs: check-labels
30-
if: needs.check-labels.outputs.run-cli-tests == 'true'
72+
if: always() && needs.check-labels.outputs.run-cli-tests == 'true'
3173
runs-on: ubuntu-latest
3274
outputs:
3375
test-files: ${{ steps.get-tests.outputs.test-files }}
@@ -53,7 +95,7 @@ jobs:
5395
pull-docker-image:
5496
needs: check-labels
5597
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'
5799
steps:
58100
- name: Log in to GitHub Container Registry
59101
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
@@ -76,7 +118,7 @@ jobs:
76118
- find-e2e-tests
77119
- pull-docker-image
78120

79-
if: needs.check-labels.outputs.run-cli-tests == 'true'
121+
if: always() && needs.check-labels.outputs.run-cli-tests == 'true'
80122
runs-on: ubuntu-latest
81123
strategy:
82124
fail-fast: false
@@ -178,7 +220,7 @@ jobs:
178220
run-unit-test:
179221
needs:
180222
- check-labels
181-
if: needs.check-labels.outputs.run-cli-tests == 'true'
223+
if: always() && needs.check-labels.outputs.run-cli-tests == 'true'
182224
runs-on: ubuntu-latest
183225
steps:
184226
- name: Check-out repository

.github/workflows/check-sdk-tests.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ jobs:
4646
github_token: ${{ secrets.GITHUB_TOKEN }}
4747
labels: run-bittensor-sdk-tests
4848

49-
# check-labels:
50-
# needs: apply-label-to-new-pr
51-
# runs-on: ubuntu-latest
52-
# if: always()
53-
# outputs:
54-
# run-sdk-tests: ${{ contains(github.event.pull_request.labels.*.name, 'run-bittensor-sdk-tests') }}
55-
# steps:
56-
# - name: Check out repository
57-
# uses: actions/checkout@v4
58-
5949
check-labels:
6050
needs: apply-label-to-new-pr
6151
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)