-
Notifications
You must be signed in to change notification settings - Fork 50
164 lines (131 loc) · 4.21 KB
/
pull_request.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Pull Request
on: [pull_request]
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: setup go
uses: actions/setup-go@v4
with:
go-version: 1.20.x
- name: checkout
uses: actions/checkout@v4
- name: lint go
uses: golangci/golangci-lint-action@v3
with:
version: v1.52
args: --timeout=5m --color=always --max-same-issues=0 --max-issues-per-linter=0
acceptance:
name: Acceptance
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: setup go
uses: actions/setup-go@v4
with:
go-version: 1.20.x
- name: checkout source
uses: actions/checkout@v4
- name: build
run: make build
- name: upload build
uses: actions/upload-artifact@v3
with:
name: konstraint-${{ matrix.os }}
path: build/konstraint
- name: unit tests
run: make test
- name: install bats ubuntu
run: sudo npm install -g bats
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: install bats macos
run: sudo npm install -g bats
if: ${{ matrix.os == 'macos-latest' }}
- name: install bats windows
run: npm install -g bats
if: ${{ matrix.os == 'windows-latest' }}
- name: acceptance tests *nix
run: make acceptance
if: ${{ matrix.os != 'windows-latest' }}
- name: acceptance tests windows
run: |
$env:Path += ";C:\npm\prefix\node_modules\bats\libexec\bats-core"
make acceptance
if: ${{ matrix.os == 'windows-latest' }}
docker-tests:
name: Docker Tests
needs: [lint]
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: docker build
run: make docker-build
- name: test create command
run: docker run -v $PWD:/konstraint konstraint create /konstraint/examples
- name: test doc command
run: docker run -v $PWD:/konstraint konstraint doc /konstraint/examples
policy-tests:
name: Policy Tests
runs-on: ubuntu-latest
container: openpolicyagent/conftest:latest
steps:
- name: checkout source
uses: actions/checkout@v4
- name: verify policy formatting
run: conftest fmt --check examples
- name: verify policies
run: conftest verify -p examples -d examples/test-data
e2e-prep:
name: Prep for End-to-end Tests
runs-on: ubuntu-latest
needs:
- lint
- acceptance
steps:
- name: checkout source
uses: actions/checkout@v4
- name: fetch gatekeeper versions
id: fetch-gk-versions
working-directory: .github/scripts
run: echo "gk-versions=$(./fetch_gk_versions.sh)" >> $GITHUB_OUTPUT
outputs:
gk-versions: ${{ steps.fetch-gk-versions.outputs.gk-versions }}
e2e:
name: End-to-end Tests
runs-on: ubuntu-latest
needs:
- e2e-prep
strategy:
matrix:
gk-version: ${{ fromJson(needs.e2e-prep.outputs.gk-versions) }}
steps:
- name: checkout source
uses: actions/checkout@v4
- name: download build
uses: actions/download-artifact@v3
with:
name: konstraint-ubuntu-latest
- name: generate resources
run: |
chmod +x ./konstraint
./konstraint create -o e2e-resources examples
./konstraint create -o e2e-resources test
- name: create kind cluster
run: kind create cluster
- name: install gatekeeper
env:
GK_VERSION: ${{ matrix.gk-version }}
run: |
helm repo add gk https://open-policy-agent.github.io/gatekeeper/charts
kubectl create ns gatekeeper-system
helm install gatekeeper gk/gatekeeper -n gatekeeper-system --set replicas=1 --version ${GK_VERSION} --set psp.enabled=false
- name: apply resources
working-directory: e2e-resources
run: |
for ct in $(ls template*); do kubectl apply -f $ct; done
sleep 60 # gatekeeper takes some time to create the CRDs
for c in $(ls constraint*); do kubectl apply -f $c; done