-
Notifications
You must be signed in to change notification settings - Fork 17
215 lines (187 loc) · 7.07 KB
/
pepr-excellent-examples.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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: E2E - Pepr Excellent Examples
permissions: read-all
on:
workflow_dispatch:
inputs:
kfcBranch:
description: 'KFC dev branch'
required: false
type: string
default: 'none'
merge_group:
paths-ignore:
- "LICENSE"
- "CODEOWNERS"
- "**.md"
schedule:
- cron: '0 4 * * *' # 12AM EST/9PM PST
push:
branches: ["main"]
pull_request:
branches: ["main"]
# refs
# https://frontside.com/blog/2022-12-12-dynamic-github-action-jobs/
# https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
jobs:
pepr-build:
name: controller image
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: clone pepr
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: defenseunicorns/pepr
path: pepr
- name: "set env: PEPR"
run: echo "PEPR=${GITHUB_WORKSPACE}/pepr" >> "$GITHUB_ENV"
- name: setup node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
cache: "npm"
cache-dependency-path: pepr
- name: install pepr deps
run: |
cd "$PEPR"
npm ci
- name: build pepr package and container image
if: ${{ (github.event.inputs.kfcBranch || 'none') == 'none' }}
run: |
cd "$PEPR"
npm run build:image
mv pepr-0.0.0-development.tgz ${GITHUB_WORKSPACE}/pepr-0.0.0-development.tgz
ls -l ${GITHUB_WORKSPACE}
- name: build pepr package and kfc dev container image
if: ${{ (github.event.inputs.kfcBranch || 'none') != 'none' }}
run: |
cd "$PEPR"
node hack/kfc-dev.js build -b "${{ github.event.inputs.kfcBranch }}"
rm -rf "$PEPR/node_modules/kubernetes-fluent-client/src"
rm -rf "$PEPR/node_modules/kubernetes-fluent-client/dist"
cp -R "$PEPR/kubernetes-fluent-client/src" "$PEPR/node_modules/kubernetes-fluent-client/src"
cp -R "$PEPR/kubernetes-fluent-client/dist" "$PEPR/node_modules/kubernetes-fluent-client/dist"
npm run build
mv pepr-0.0.0-development.tgz ${GITHUB_WORKSPACE}/pepr-0.0.0-development.tgz
ls -l ${GITHUB_WORKSPACE}
- name: tar pepr image
run: |
PEPR_TAR="${GITHUB_WORKSPACE}/pepr-img.tar"
echo "PEPR_TAR=${PEPR_TAR}" >> "$GITHUB_ENV"
docker image save --output "$PEPR_TAR" pepr:dev
- name: upload artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: pepr-package-and-controller-image
path: |
pepr-0.0.0-development.tgz
pepr-img.tar
if-no-files-found: error
retention-days: 1
examples-matrix:
name: job matrix
runs-on: ubuntu-latest
needs:
- pepr-build
outputs:
matrix: ${{ steps.create-matrix.outputs.matrix }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: clone pepr
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: defenseunicorns/pepr
path: pepr
- name: "set env: PEPR"
run: echo "PEPR=${GITHUB_WORKSPACE}/pepr" >> "$GITHUB_ENV"
- name: clone pepr-excellent-examples
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: defenseunicorns/pepr-excellent-examples
path: pepr-excellent-examples
- name: "set env: PEPR_EXCELLENT_EXAMPLES_PATH"
run: echo "PEPR_EXCELLENT_EXAMPLES_PATH=${GITHUB_WORKSPACE}/pepr-excellent-examples" >> "$GITHUB_ENV"
- name: setup node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
cache: "npm"
cache-dependency-path: pepr
- name: create matrix
run: |
matrix=$(
node "$PEPR/.github/workflows/pepr-excellent-examples-matrix.js" "$PEPR_EXCELLENT_EXAMPLES_PATH"
)
echo "matrix=${matrix}" >> "$GITHUB_OUTPUT"
id: create-matrix
excellent-examples:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
needs:
- examples-matrix
if: needs.examples-matrix.outputs.matrix != ''
strategy:
fail-fast: false
max-parallel: 32 # Roughly matches the number of E2E tests and below GitHub concurrency limit
matrix: ${{ fromJSON(needs.examples-matrix.outputs.matrix) }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: "install k3d"
run: "curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash"
shell: bash
- name: download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: pepr-package-and-controller-image
path: ${{ github.workspace }}
- name: import pepr image from tar
run: |
PEPR_TAR="${GITHUB_WORKSPACE}/pepr-img.tar"
echo "PEPR_TAR=${PEPR_TAR}" >> "$GITHUB_ENV"
docker image load --input "$PEPR_TAR"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: defenseunicorns/pepr-excellent-examples
path: pepr-excellent-examples
- name: "set env: PEPR_EXCELLENT_EXAMPLES_PATH"
run: echo "PEPR_EXCELLENT_EXAMPLES_PATH=${GITHUB_WORKSPACE}/pepr-excellent-examples" >> "$GITHUB_ENV"
- name: setup node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
cache: "npm"
cache-dependency-path: pepr-excellent-examples
- name: install pepr-excellent-examples deps
run: |
cd "$PEPR_EXCELLENT_EXAMPLES_PATH"
npm ci
- name: run e2e tests
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
with:
max_attempts: 3
retry_on: error
timeout_minutes: 6
command: |
cd "$PEPR_EXCELLENT_EXAMPLES_PATH"
npm run --workspace=${{ matrix.name }} test:e2e -- \
--image pepr:dev \
--custom-package ../pepr-0.0.0-development.tgz
- name: upload artifacts (troubleshooting)
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
if: always()
with:
name: "troubleshooting_logs_${{matrix.name}}"
path: |
pepr-excellent-examples/package.json
pepr-excellent-examples/package-lock.json
if-no-files-found: error
retention-days: 1