-
Notifications
You must be signed in to change notification settings - Fork 83
216 lines (182 loc) · 5.91 KB
/
pull_request.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
216
---
name: CI
on: # yamllint disable-line rule:truthy
pull_request: # yamllint disable-line rule:empty-values
env:
DESIRED_GO_VERSION: '1.22'
DESIRED_GOLANGCI_LINT_VERSION: 'v1.60'
DESIRED_PYTHON_VERSION: '3.12'
jobs:
lint-receptor:
name: lint-receptor
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: ${{ env.DESIRED_GO_VERSION }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: ${{ env.DESIRED_GOLANGCI_LINT_VERSION }}
receptor:
name: receptor (Go ${{ matrix.go-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: ["1.22"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: build and install receptor
run: |
make build-all
sudo cp ./receptor /usr/local/bin/receptor
- name: Download kind binary
run: curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64 && chmod +x ./kind
- name: Create k8s cluster
run: ./kind create cluster
- name: Interact with the cluster
run: kubectl get nodes
- name: Run receptor tests
run: make test
- name: get k8s logs
if: ${{ failure() }}
run: .github/workflows/artifact-k8s-logs.sh
- name: remove sockets before archiving logs
if: ${{ failure() }}
run: find /tmp/receptor-testing -name controlsock -delete
- name: Artifact receptor data for ${{ matrix.go-version }}
uses: actions/upload-artifact@v4.4.3
if: ${{ failure() }}
with:
name: test-logs-${{ matrix.go-version }}
path: /tmp/receptor-testing
- name: Archive receptor binary for ${{ matrix.go-version }}
uses: actions/upload-artifact@v4.4.3
with:
name: receptor-${{ matrix.go-version }}
path: /usr/local/bin/receptor
receptorctl:
name: Run receptorctl tests${{ '' }} # Nest jobs under the same sidebar category
needs: receptor
strategy:
fail-fast: false
matrix:
python-version:
# NOTE: The highest and the lowest versions come
# NOTE: first as their statuses are most likely to
# NOTE: signal problems early:
- 3.12
- 3.8
- 3.11
- "3.10"
- 3.9
uses: ./.github/workflows/reusable-nox.yml
with:
python-version: ${{ matrix.python-version }}
session: tests-${{ matrix.python-version }}
download-receptor: true
go-version: '1.22'
lint-receptorctl:
name: Lint receptorctl${{ '' }} # Nest jobs under the same sidebar category
strategy:
fail-fast: false
matrix:
session:
- check_style
- check_format
uses: ./.github/workflows/reusable-nox.yml
with:
python-version: '3.12'
session: ${{ matrix.session }}
container:
name: container
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.DESIRED_PYTHON_VERSION }}
- name: Install python dependencies
run: pip install build
- name: Build container
run: make container REPO=receptor LATEST=yes
- name: Write out basic config
run: |
cat << EOF > test.cfg
---
- local-only:
- control-service:
service: control
filename: /tmp/receptor.sock
- work-command:
worktype: cat
command: cat
EOF
- name: Run receptor (and wait a few seconds for it to boot)
run: |
podman run --name receptor -d -v $PWD/test.cfg:/etc/receptor/receptor.conf:Z localhost/receptor
sleep 3
podman logs receptor
- name: Submit work and assert the output we expect
run: |
output=$(podman exec -i receptor receptorctl work submit cat -l 'hello world' -f)
echo $output
if [[ "$output" != "hello world" ]]; then
echo "Output did not contain expected value"
exit 1
fi
receptorctl-test-coverage:
name: Receptorctl test coverage
needs: receptor
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
session:
- coverage
steps:
- name: Download the `receptor` binary
uses: actions/download-artifact@v4
with:
name: receptor-${{ env.DESIRED_GO_VERSION }}
path: /usr/local/bin/
- name: Set executable bit on the `receptor` binary
run: sudo chmod a+x /usr/local/bin/receptor
- name: Set up nox
uses: wntrblm/nox@2024.10.09
with:
python-versions: ${{ env.DESIRED_PYTHON_VERSION }}
- name: Check out the source code from Git
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for the automation in Nox to find the last tag
- name: Provision nox environment for ${{ matrix.session }}
run: nox --install-only --session ${{ matrix.session }}
working-directory: ./receptorctl
- name: Run `receptorctl` nox ${{ matrix.session }} session
run: nox --no-install --session ${{ matrix.session }}
working-directory: ./receptorctl
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
directory: receptorctl
files: receptorctl_coverage.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true