-
Notifications
You must be signed in to change notification settings - Fork 28
99 lines (87 loc) · 2.99 KB
/
pr-quality-gate.yaml
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: "PR Quality Gate"
on:
pull_request:
types:
# default types...
- opened
- synchronize
- reopened
# custom types...
- labeled
jobs:
select-providers:
runs-on: ubuntu-22.04
outputs:
providers: ${{ steps.determine-providers.outputs.providers }}
steps:
- uses: actions/checkout@v3
with:
# in order to properly resolve the version from git
fetch-depth: 0
- name: Bootstrap environment
uses: ./.github/actions/bootstrap
with:
tools: false
- name: Determine providers
id: determine-providers
run: |
# be nice to folks troubleshooting in CI...
cd tests/quality
poetry run make show-changes
# determine which providers to run (to later populate the matrix)
content=`poetry run make select-providers`
echo $content
echo "providers=$content" >> $GITHUB_OUTPUT
validate-provider:
runs-on: ubuntu-22.04
needs: select-providers
if: contains(github.event.pull_request.labels.*.name, 'run-pr-quality-gate')
strategy:
matrix:
provider: ${{fromJson(needs.select-providers.outputs.providers)}}
fail-fast: false
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@v3
with:
# in order to properly resolve the version from git
fetch-depth: 0
# we need submodules for the quality gate to work (requires vulnerability-match-labels repo)
submodules: true
- name: Bootstrap environment
uses: ./.github/actions/bootstrap
with:
go: true
- name: Run quality gate
uses: ./.github/actions/quality-gate
with:
provider: ${{ matrix.provider }}
env:
# needed as a secret for the github provider
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
evaluate-quality-gate:
runs-on: ubuntu-22.04
needs:
- validate-provider
- select-providers
if: ${{ always() }}
steps:
- run: |
echo "Validations Status: ${{ needs.validate-provider.result }}"
echo "Providers that require testing: ${{ needs.select-providers.outputs.providers }}"
echo
if [ '${{ needs.select-providers.outputs.providers }}' == '[]' ]; then
echo "🟢 Quality gate passed! (no providers changed)"
exit 0
fi
if [ "${{ needs.validate-provider.result }}" != "success" ]; then
echo "🔴 Quality gate FAILED! 😭"
echo
echo "This could happen for a couple of reasons:"
echo " - A provider test failed, in which case see the logs in previous jobs for more details"
echo " - A required provider test was skipped. You might need to add the 'run-pr-quality-gate' label to your PR to prevent skipping the test."
exit 1
fi
echo "🟢 Quality gate passed! (all tests passed)"