Skip to content

Commit b115d85

Browse files
authored
Merge pull request #2070 from stratosphereips/develop
Slips v1.1.23
2 parents 330dd01 + ee2d8b2 commit b115d85

327 files changed

Lines changed: 44531 additions & 6616 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
modules/ml_linear_model/artifacts/* filter=lfs diff=lfs merge=lfs -text
2+
modules/ml_online_model/artifacts/* filter=lfs diff=lfs merge=lfs -text

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ updates:
55
target-branch: "develop"
66
schedule:
77
interval: "daily"
8+
cooldown:
9+
default-days: 7
810

911
- package-ecosystem: "github-actions"
1012
directory: "/"
1113
target-branch: "develop"
1214
schedule:
1315
interval: "daily"
16+
cooldown:
17+
default-days: 7
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Runs unit and integration tests for Dependabot PRs to develop.
2+
# Unlike the regular unit-tests/integration-tests workflows (which use the
3+
# prebuilt stratosphereips/slips_dependencies image from Docker Hub), this
4+
# builds a fresh Docker image from docker/Dockerfile and runs the tests inside
5+
# it, so dependency bumps are validated against a newly built image.
6+
7+
name: dependabot-develop-tests
8+
9+
on:
10+
pull_request:
11+
branches:
12+
- 'develop'
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
build-docker-image:
19+
name: Build Docker image
20+
# Only run for Dependabot-authored pull requests.
21+
if: ${{ github.actor == 'dependabot[bot]' }}
22+
runs-on: ubuntu-22.04
23+
timeout-minutes: 120
24+
outputs:
25+
docker_image_artifact_name: ${{ steps.image.outputs.artifact_name }}
26+
docker_image_tag: ${{ steps.image.outputs.image_tag }}
27+
steps:
28+
- uses: actions/checkout@v7
29+
with:
30+
ref: ${{ github.ref }}
31+
fetch-depth: 0
32+
lfs: true
33+
34+
- name: Prepare Docker image metadata
35+
id: image
36+
run: |
37+
image_tag="slips-dependabot-develop-tests:${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
38+
artifact_name="slips-dependabot-develop-tests-image-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
39+
echo "image_tag=$image_tag" >> "$GITHUB_OUTPUT"
40+
echo "artifact_name=$artifact_name" >> "$GITHUB_OUTPUT"
41+
42+
- name: Build Docker image
43+
uses: ./.github/workflows/reusable/build-docker-image
44+
with:
45+
artifact_name: ${{ steps.image.outputs.artifact_name }}
46+
image_tag: ${{ steps.image.outputs.image_tag }}
47+
48+
unit-tests:
49+
if: ${{ always() && needs.build-docker-image.result == 'success' }}
50+
needs:
51+
- build-docker-image
52+
uses: ./.github/workflows/test-suite.yml
53+
with:
54+
test_suite_name: unit-tests
55+
test_dir: tests/unit
56+
test_path_prefix: tests/unit/
57+
pytest_workers: "5"
58+
timeout_minutes: 120
59+
output_path: output/unit_tests
60+
artifact_name_prefix: test_slips-output-
61+
container_prefix: slips-unit
62+
docker_image_artifact_name: ${{ needs.build-docker-image.outputs.docker_image_artifact_name }}
63+
docker_image_tag: ${{ needs.build-docker-image.outputs.docker_image_tag }}
64+
setup_venv: true
65+
66+
integration-tests:
67+
if: ${{ always() && needs.build-docker-image.result == 'success' }}
68+
needs:
69+
- build-docker-image
70+
uses: ./.github/workflows/test-suite.yml
71+
with:
72+
test_suite_name: integration-tests
73+
test_dir: tests/integration
74+
output_prefix: integration/
75+
test_path_prefix: tests/
76+
pytest_workers: "3"
77+
timeout_minutes: 1800
78+
output_path: output/integration_tests
79+
artifact_name_suffix: -integration-output
80+
container_prefix: slips-integration
81+
docker_image_artifact_name: ${{ needs.build-docker-image.outputs.docker_image_artifact_name }}
82+
docker_image_tag: ${{ needs.build-docker-image.outputs.docker_image_tag }}
83+
setup_venv: true

.github/workflows/dockerfile-pr-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
with:
3838
ref: ${{ github.ref }}
3939
fetch-depth: 0
40+
lfs: true
4041

4142
- name: Prepare Docker image metadata
4243
id: image

.github/workflows/integration-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88

99
jobs:
1010
integration-tests:
11+
# Dependabot PRs to develop are handled by dependabot-develop-tests.yml,
12+
# which runs the tests on a freshly built Docker image instead.
13+
if: ${{ github.actor != 'dependabot[bot]' }}
1114
uses: ./.github/workflows/test-suite.yml
1215
with:
1316
test_suite_name: integration-tests

.github/workflows/publish-slips-images.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ jobs:
7171
fetch-depth: 0
7272
# submodules are needed for local and global p2p
7373
submodules: true
74+
# without this, LFS-tracked files (e.g. ml_online_model/ml_linear_model
75+
# artifacts) are checked out as pointer text files instead of the
76+
# real binaries, breaking those models in the published images
77+
lfs: true
7478

7579
- name: Login to DockerHub
76-
uses: docker/login-action@v4
80+
uses: docker/login-action@v4.5.2
7781
with:
7882
username: stratosphereips
7983
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

.github/workflows/reusable/build-docker-image/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ runs:
2828
ref: ${{ github.ref }}
2929
fetch-depth: 0
3030
submodules: recursive
31+
lfs: true
3132

3233
- name: Validate Docker build context
3334
shell: bash

.github/workflows/reusable/list-tests-dir/action.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inputs:
1010
default: ""
1111
outputs:
1212
test_files:
13-
description: "JSON array of integration test files (relative to tests/)"
13+
description: "JSON array of test file metadata objects"
1414
value: ${{ steps.set-matrix.outputs.files }}
1515

1616
runs:
@@ -19,7 +19,18 @@ runs:
1919
- id: set-matrix
2020
shell: bash
2121
run: |
22-
# Find files in test_dir/ and optionally prefix entries for consumers.
2322
PREFIX="${{ inputs.output_prefix }}"
24-
FILES=$(find "${{ inputs.test_dir }}" -name "test_*.py" -printf "%P\n" | sed "s|^|${PREFIX}|" | jq -R -s -c 'split("\n")[:-1]')
23+
FILES=$(find "${{ inputs.test_dir }}" -name "test_*.py" -printf "%P\n" | jq -R -s -c --arg prefix "$PREFIX" '
24+
split("\n")[:-1]
25+
| map({
26+
test_file: ($prefix + .),
27+
display_name: (
28+
split("/")
29+
| if length >= 2
30+
then .[-2] + "/" + .[-1]
31+
else .[-1]
32+
end
33+
)
34+
})
35+
')
2536
echo "files=$FILES" >> "$GITHUB_OUTPUT"

.github/workflows/reusable/run-test-file/action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ inputs:
3737
description: "Matrix job index for unique Docker container names"
3838
required: false
3939
default: "0"
40+
setup_venv:
41+
description: "Create a fresh python3.10 venv, install install/requirements.txt into it, and run the tests with it (docker execution mode only)"
42+
required: false
43+
default: "false"
4044

4145
runs:
4246
using: "composite"
@@ -66,6 +70,7 @@ runs:
6670
OUTPUT_PATH: ${{ inputs.output_path }}
6771
CONTAINER_PREFIX: ${{ inputs.container_prefix }}
6872
JOB_INDEX: ${{ inputs.job_index }}
73+
SETUP_VENV: ${{ inputs.setup_venv }}
6974
run: |
7075
mkdir -p "$OUTPUT_PATH"
7176
container_name="${CONTAINER_PREFIX}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-${JOB_INDEX}"
@@ -78,6 +83,7 @@ runs:
7883
-e TEST_FILE="$TEST_FILE" \
7984
-e TEST_PATH_PREFIX="$TEST_PATH_PREFIX" \
8085
-e PYTEST_WORKERS="$PYTEST_WORKERS" \
86+
-e SETUP_VENV="$SETUP_VENV" \
8187
"$IMAGE_TAG" \
8288
bash -lc '
8389
set -e
@@ -92,6 +98,16 @@ runs:
9298
fi
9399
sleep 0.5
94100
done
101+
if [ "$SETUP_VENV" = "true" ]; then
102+
# Validate this PR against a fresh venv built only from the PRs
103+
# install/requirements.txt, rather than the image-baked packages.
104+
apt-get update
105+
apt-get install -y --no-install-recommends python3.10-venv
106+
python3.10 -m venv /tmp/slips-venv
107+
. /tmp/slips-venv/bin/activate
108+
python3 -m pip install --upgrade pip
109+
python3 -m pip install -r install/requirements.txt
110+
fi
95111
python3 -m pytest "${TEST_PATH_PREFIX}${TEST_FILE}" -p no:warnings -vv -s -n "$PYTEST_WORKERS"
96112
'
97113

.github/workflows/test-suite.yml

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
#image_tag_prefix: slips-my-tests
1818
#container_prefix: slips-my-tess
1919

20+
21+
# this file runs either
22+
# build-docker-image -> dockerfile-image-tests
23+
# or
24+
# dependency-image-tests -> prebuilt-docker-image-tests
25+
26+
2027
name: test-suite
2128

2229
on:
@@ -86,6 +93,11 @@ on:
8693
required: false
8794
default: ""
8895
type: string
96+
setup_venv:
97+
description: "Inside the test container, create a fresh python3.10 venv, install install/requirements.txt into it, and run the tests with it"
98+
required: false
99+
default: false
100+
type: boolean
89101

90102
jobs:
91103
list-tests:
@@ -115,6 +127,7 @@ jobs:
115127
with:
116128
ref: ${{ github.ref }}
117129
fetch-depth: 0
130+
lfs: true
118131

119132
- name: Prepare Docker image metadata
120133
id: image
@@ -132,7 +145,7 @@ jobs:
132145

133146
dependency-image-tests:
134147
# runs slips tests inside a pre-built slips dependency docker image at stratosphereips/slips_dependencies
135-
name: ${{ inputs.test_suite_name }}
148+
name: "${{ matrix.display_name && format('{0} / {1}', inputs.test_suite_name, matrix.display_name) || format('{0} (dependency image)', inputs.test_suite_name) }}"
136149
if: ${{ !inputs.build_dockerfile && inputs.docker_image_artifact_name == '' && inputs.docker_image_tag == '' }}
137150
needs: list-tests
138151
runs-on: ubuntu-22.04
@@ -150,13 +163,20 @@ jobs:
150163
strategy:
151164
fail-fast: false
152165
matrix:
153-
test_file: ${{ fromJson(needs.list-tests.outputs.test_files) }}
166+
include: ${{ fromJson(needs.list-tests.outputs.test_files) }}
154167

155168
steps:
169+
- name: Install git-lfs
170+
run: |
171+
apt-get update
172+
apt-get install -y --no-install-recommends git-lfs
173+
git lfs install
174+
156175
- uses: actions/checkout@v7
157176
with:
158177
ref: ${{ github.ref }}
159178
fetch-depth: 0
179+
lfs: true
160180

161181
- name: Run ${{ inputs.test_suite_name }} for ${{ matrix.test_file }}
162182
uses: ./.github/workflows/reusable/run-test-file
@@ -169,9 +189,10 @@ jobs:
169189
artifact_name: ${{ inputs.artifact_name_prefix && format('{0}{1}', inputs.artifact_name_prefix, strategy.job-index) || '' }}
170190
artifact_name_suffix: ${{ inputs.artifact_name_suffix }}
171191

192+
172193
dockerfile-image-tests:
173-
# runs slips tests inside a newly created docker image from docker/Dockerfile
174-
name: ${{ inputs.test_suite_name }}
194+
# runs slips tests inside a newly built img from the "build-docker-image" step.
195+
name: "${{ matrix.display_name && format('{0} / {1}', inputs.test_suite_name, matrix.display_name) || format('{0} (build dockerfile)', inputs.test_suite_name) }}"
175196
if: ${{ inputs.build_dockerfile }}
176197
needs:
177198
- list-tests
@@ -186,16 +207,17 @@ jobs:
186207
strategy:
187208
fail-fast: false
188209
matrix:
189-
test_file: ${{ fromJson(needs.list-tests.outputs.test_files) }}
210+
include: ${{ fromJson(needs.list-tests.outputs.test_files) }}
190211

191212
steps:
192213
- uses: actions/checkout@v7
193214
with:
194215
ref: ${{ github.ref }}
195216
fetch-depth: 0
217+
lfs: true
196218

197219
- name: Download Docker Image
198-
uses: actions/download-artifact@v5
220+
uses: actions/download-artifact@v8
199221
with:
200222
name: ${{ needs.build-docker-image.outputs.artifact_name }}
201223

@@ -218,7 +240,7 @@ jobs:
218240

219241
prebuilt-docker-image-tests:
220242
# runs slips tests inside a Docker image built by the caller and passed as an artifact
221-
name: ${{ inputs.test_suite_name }}
243+
name: "${{ matrix.display_name && format('{0} / {1}', inputs.test_suite_name, matrix.display_name) || format('{0} (prebuilt image)', inputs.test_suite_name) }}"
222244
if: ${{ !inputs.build_dockerfile && inputs.docker_image_artifact_name != '' && inputs.docker_image_tag != '' }}
223245
needs: list-tests
224246
runs-on: ubuntu-22.04
@@ -231,16 +253,17 @@ jobs:
231253
strategy:
232254
fail-fast: false
233255
matrix:
234-
test_file: ${{ fromJson(needs.list-tests.outputs.test_files) }}
256+
include: ${{ fromJson(needs.list-tests.outputs.test_files) }}
235257

236258
steps:
237259
- uses: actions/checkout@v7
238260
with:
239261
ref: ${{ github.ref }}
240262
fetch-depth: 0
263+
lfs: true
241264

242265
- name: Download Docker Image
243-
uses: actions/download-artifact@v5
266+
uses: actions/download-artifact@v8
244267
with:
245268
name: ${{ inputs.docker_image_artifact_name }}
246269

@@ -260,3 +283,4 @@ jobs:
260283
image_tag: ${{ inputs.docker_image_tag }}
261284
container_prefix: ${{ inputs.container_prefix }}
262285
job_index: ${{ strategy.job-index }}
286+
setup_venv: ${{ inputs.setup_venv }}

0 commit comments

Comments
 (0)