-
Notifications
You must be signed in to change notification settings - Fork 12
59 lines (58 loc) · 1.81 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Test Everything
on:
pull_request:
jobs:
test-job:
name: All Tests
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-go@v2
with:
go-version: '1.20.5'
id: go
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: labels } = await github.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const labelToRemove = 'tests-passed';
const labelExists = labels.some(label => label.name === labelToRemove);
console.log("labelExists: ", labelExists);
if (labelExists) {
await github.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: labelToRemove
});
}
- name: Run Tests
run: |
echo "Git HEAD at: $(git rev-parse HEAD)"
./scripts/test || ./scripts/test || ./scripts/test
success-job:
needs: test-job
name: Add Label
runs-on: ubuntu-20.04
steps:
- uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['tests-passed']
})