-
Notifications
You must be signed in to change notification settings - Fork 13
294 lines (246 loc) · 8.97 KB
/
Copy pathtests.yml
File metadata and controls
294 lines (246 loc) · 8.97 KB
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
name: Tests
on:
push:
pull_request:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
python:
name: Python tests (${{ matrix.python-version }})
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-dev.txt
- name: Run Python tests
env:
PYTHONPATH: lib/python:cli/python
run: |
python -m pytest
bats:
name: BATS tests
runs-on: ubuntu-latest
timeout-minutes: 20
env:
BASE_BASH_LIBS_DIR: ${{ github.workspace }}/.dependencies/base-bash-libs/lib/bash
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
repository: basefoundry/base-bash-libs
ref: 424ef9fe61bc8a462ba9980ea63b38dd202ec242
path: .dependencies/base-bash-libs
- name: Install BATS
run: |
sudo apt-get update
sudo apt-get install -y bats
- name: Run BATS tests
run: |
bats \
cli/bash/commands/basectl/tests/*.bats \
lib/bash/runtime/tests/runtime_bashrc.bats \
lib/bash/version/tests/lib_version.bats \
lib/shell/completions/tests/completions.bats \
tests/base_test.bats \
tests/base_init.bats \
tests/bootstrap.bats \
tests/install.bats \
tests/source_guards.bats
macos:
name: macOS smoke tests
runs-on: macos-14
timeout-minutes: 25
env:
BASE_BASH_LIBS_DIR: ${{ github.workspace }}/.dependencies/base-bash-libs/lib/bash
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
repository: basefoundry/base-bash-libs
ref: 424ef9fe61bc8a462ba9980ea63b38dd202ec242
path: .dependencies/base-bash-libs
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: "3.13"
- name: Install Homebrew tools
run: |
brew install bash bats-core
echo "$(brew --prefix)/bin" >> "$GITHUB_PATH"
- name: Run bootstrap dry-run install-route checks
run: |
require_output() {
case "$1" in
*"$2"*) ;;
*)
printf "Expected bootstrap output to include: %s\n" "$2" >&2
return 1
;;
esac
}
brew_output="$(./bootstrap.sh --dry-run --brew)"
printf '%s\n' "$brew_output"
require_output "$brew_output" "basectl setup"
require_output "$brew_output" "basectl update-profile"
source_output="$(./bootstrap.sh --dry-run --source --install-dir "$GITHUB_WORKSPACE")"
printf '%s\n' "$source_output"
require_output "$source_output" "basectl setup"
require_output "$source_output" "basectl update-profile"
- name: Run Base setup and check smoke tests
run: |
./bin/basectl ci setup base --format json
./bin/basectl ci check base --format json
- name: Verify shell profile integration
run: |
test_home="$(mktemp -d)"
brew_bash="$(brew --prefix)/bin/bash"
HOME="$test_home" ./bin/basectl update-profile
test -f "$test_home/.bash_profile"
test -f "$test_home/.bashrc"
env -u BASE_HOME \
HOME="$test_home" \
PATH="/usr/bin:/bin:/usr/sbin:/sbin" \
"$brew_bash" --rcfile "$test_home/.bashrc" -i -c 'command -v basectl >/dev/null && basectl --version'
- name: Run focused macOS BATS tests
run: |
bats \
cli/bash/commands/basectl/tests/update-profile.bats \
lib/bash/version/tests/lib_version.bats \
lib/shell/completions/tests/completions.bats \
tests/base_init.bats \
tests/install.bats
integration:
name: Integration tests
runs-on: ubuntu-latest
timeout-minutes: 25
env:
BASE_BASH_LIBS_DIR: ${{ github.workspace }}/.dependencies/base-bash-libs/lib/bash
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
repository: basefoundry/base-bash-libs
ref: 424ef9fe61bc8a462ba9980ea63b38dd202ec242
path: .dependencies/base-bash-libs
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: "3.13"
- name: Install dependencies
run: |
python -m venv .integration-venv
.integration-venv/bin/python -m pip install --upgrade pip
.integration-venv/bin/python -m pip install -r requirements-dev.txt
mkdir -p "$HOME/.base.d/base"
python -m venv "$HOME/.base.d/base/.venv"
"$HOME/.base.d/base/.venv/bin/python" -m pip install --upgrade pip
"$HOME/.base.d/base/.venv/bin/python" -m pip install -r requirements-dev.txt
sudo apt-get update
sudo apt-get install -y bats
- name: Run basectl ci smoke check
run: |
./bin/basectl ci check base --format json
- name: Run integration tests
env:
BASE_INTEGRATION_PYTHON: ${{ github.workspace }}/.integration-venv/bin/python
run: |
bats tests/integration/base_workflows.bats
ubuntu-source-checkout:
name: Ubuntu source-checkout suite
runs-on: ubuntu-latest
timeout-minutes: 35
env:
BASE_BASH_LIBS_DIR: ${{ github.workspace }}/.dependencies/base-bash-libs/lib/bash
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
repository: basefoundry/base-bash-libs
ref: 424ef9fe61bc8a462ba9980ea63b38dd202ec242
path: .dependencies/base-bash-libs
- name: Expose reusable Bash library checkout as sibling
run: |
ln -s "$GITHUB_WORKSPACE/.dependencies/base-bash-libs" "$GITHUB_WORKSPACE/../base-bash-libs"
- name: Install Ubuntu source-checkout prerequisites
run: |
sudo apt-get update
sudo apt-get install -y \
git \
curl \
build-essential \
ca-certificates \
python3-venv \
python3-pip \
bats \
shellcheck \
jq \
golang-go
- name: Prepare Base test virtual environment
run: |
mkdir -p "$HOME/.base.d/base"
python3 -m venv "$HOME/.base.d/base/.venv"
"$HOME/.base.d/base/.venv/bin/python" -m pip install --upgrade pip
"$HOME/.base.d/base/.venv/bin/python" -m pip install -r requirements-dev.txt
- name: Run Ubuntu source-checkout validation
run: |
./bin/basectl ci check base --format json
env -u BASE_HOME ./bin/base-test
security:
name: Security scanners
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: "3.13"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-dev.txt
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Run Bandit
run: |
bandit -q -r cli/python lib/python -x '*/tests/*' --severity-level medium
- name: Run pip-audit
run: |
python -m pip_audit --cache-dir "$RUNNER_TEMP/pip-audit" -r requirements-dev.txt
- name: Run ShellCheck
run: |
git ls-files -z \
'*.sh' \
'base_init.sh' \
'install.sh' \
'lib/bash/runtime/bashrc' \
'bin/*' \
| xargs -0 shellcheck --severity=error
- name: Run ShellCheck warnings
continue-on-error: true
run: |
git ls-files -z \
'*.sh' \
'base_init.sh' \
'install.sh' \
'lib/bash/runtime/bashrc' \
'bin/*' \
| xargs -0 shellcheck --severity=warning --format=tty