Skip to content

Commit 5e0acb5

Browse files
Merge pull request #3813 from SwiftPackageIndex/enable-experimental-prebuilts
Speed up GH build pipeline
2 parents a7572ea + f16da2a commit 5e0acb5

File tree

7 files changed

+118
-28
lines changed

7 files changed

+118
-28
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM registry.gitlab.com/finestructure/spi-base:1.2.0
1+
FROM registry.gitlab.com/finestructure/spi-base:1.2.2
22

33
# Install SPM build dependencies
44
RUN apt-get update && apt-get install -y curl git make unzip \

.github/workflows/ci.yml

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,43 @@ jobs:
2929
name: Test
3030
runs-on: ubuntu-latest
3131
container:
32-
image: registry.gitlab.com/finestructure/spi-base:1.2.0
32+
image: registry.gitlab.com/finestructure/spi-base:1.2.2
3333
options: --privileged
3434
steps:
3535
- name: GH Runner bug workaround
3636
run: sysctl -w vm.mmap_rnd_bits=28
37+
3738
- name: Checkout code
3839
uses: actions/checkout@v4
3940
with: { 'fetch-depth': 0 }
40-
- name: Install unzip
41-
run: apt-get update && apt-get install -y unzip
41+
42+
- name: Install unzip (for tests) and zstd (for faster caching)
43+
run: apt-get update && apt-get install -y unzip zstd
44+
45+
- name: Restore .build
46+
if: ${{ !(github.run_attempt > 1) }} # Because maybe the cache is causing issues
47+
id: "restore-cache"
48+
uses: actions/cache/restore@v4
49+
with:
50+
path: .build
51+
key: "spi-debug-build-${{ runner.os }}-${{ github.event.after }}"
52+
restore-keys: "spi-debug-build-${{ runner.os }}-"
53+
54+
- name: Build tests
55+
run: cp .env.testing.template .env.testing && make build-tests
56+
57+
- name: Cache .build
58+
if: steps.restore-cache.outputs.cache-hit != 'true'
59+
uses: actions/cache/save@v4
60+
with:
61+
path: .build
62+
key: "spi-debug-build-${{ runner.os }}-${{ github.event.after }}"
63+
4264
- name: Run tests
43-
run: cp .env.testing.template .env.testing && make test
65+
run: cp .env.testing.template .env.testing && make run-tests
4466
env:
4567
COLLECTION_SIGNING_PRIVATE_KEY: ${{ secrets.COLLECTION_SIGNING_PRIVATE_KEY }}
68+
4669
services:
4770
spi_test_0:
4871
image: postgres:16-alpine
@@ -137,20 +160,44 @@ jobs:
137160
name: Release build
138161
runs-on: ubuntu-latest
139162
container:
140-
image: registry.gitlab.com/finestructure/spi-base:1.2.0
163+
image: registry.gitlab.com/finestructure/spi-base:1.2.2
141164
options: --privileged
142165
steps:
143166
- name: GH Runner bug workaround
144167
run: sysctl -w vm.mmap_rnd_bits=28
168+
145169
- name: Checkout code
146170
uses: actions/checkout@v4
147171
with: { 'fetch-depth': 0 }
148-
- name: Test release
172+
173+
- name: Install zstd (for faster caching)
174+
run: apt-get update && apt-get install -y zstd
175+
176+
- name: Restore .build
177+
if: ${{ !(github.run_attempt > 1) }} # Because maybe the cache is causing issues
178+
id: "restore-cache"
179+
uses: actions/cache/restore@v4
180+
with:
181+
path: .build
182+
key: "spi-release-build-${{ runner.os }}-${{ github.event.after }}"
183+
restore-keys: "spi-release-build-${{ runner.os }}-"
184+
185+
- name: Build release
149186
run: |
150187
# Since we're only pinging the version api endpoint, no database is needed and
151188
# we can just copy the development template to ensure the db env variables are set.
152189
cp .env.development.template .env.development
153-
swift build -c release --static-swift-stdlib -Xlinker -ljemalloc
190+
swift build -c release --static-swift-stdlib -Xlinker -ljemalloc --enable-experimental-prebuilts
191+
192+
- name: Cache .build
193+
if: steps.restore-cache.outputs.cache-hit != 'true'
194+
uses: actions/cache/save@v4
195+
with:
196+
path: .build
197+
key: "spi-release-build-${{ runner.os }}-${{ github.event.after }}"
198+
199+
- name: Test release
200+
run: |
154201
$(swift build --show-bin-path -c release)/Run serve --port 8080 --hostname 0.0.0.0 &
155202
sleep 10
156203
echo Probing api/version...

.github/workflows/query-performance.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,34 @@ jobs:
2828
runs-on: ubuntu-latest
2929
continue-on-error: true
3030
container:
31-
image: registry.gitlab.com/finestructure/spi-base:1.2.0
31+
image: registry.gitlab.com/finestructure/spi-base:1.2.2
3232
steps:
3333
- name: Checkout code
3434
uses: actions/checkout@v4
3535
with: { 'fetch-depth': 0 }
36-
- name: Install unzip
37-
run: apt-get update && apt-get install -y unzip
36+
37+
- name: Install unzip (for tests) and zstd (for faster caching)
38+
run: apt-get update && apt-get install -y unzip zstd
39+
40+
- name: Restore .build
41+
if: ${{ !(github.run_attempt > 1) }} # Because maybe the cache is causing issues
42+
id: "restore-cache"
43+
uses: actions/cache/restore@v4
44+
with:
45+
path: .build
46+
key: "spi-query-performance-build-${{ runner.os }}-${{ github.event.after }}"
47+
restore-keys: "spi-query-performance-build-${{ runner.os }}-"
48+
49+
- name: Build tests
50+
run: cp .env.testing.template .env.testing && make build-tests
51+
52+
- name: Cache .build
53+
if: steps.restore-cache.outputs.cache-hit != 'true'
54+
uses: actions/cache/save@v4
55+
with:
56+
path: .build
57+
key: "spi-query-performance-build-${{ runner.os }}-${{ github.event.after }}"
58+
3859
- name: Run tests
3960
run: |
4061
echo "
@@ -45,4 +66,4 @@ jobs:
4566
DATABASE_USE_TLS=true
4667
DATABASE_USERNAME=spi_dev
4768
" >> .env.staging
48-
make test-query-performance
69+
make run-query-performance-tests

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# ================================
1919
# Build image
2020
# ================================
21-
FROM registry.gitlab.com/finestructure/spi-base:1.2.0 as build
21+
FROM registry.gitlab.com/finestructure/spi-base:1.2.2 as build
2222

2323
# Set up a build area
2424
WORKDIR /build
@@ -37,6 +37,7 @@ COPY . .
3737
# Build everything, with optimizations, with static linking, and using jemalloc
3838
# N.B.: The static version of jemalloc is incompatible with the static Swift runtime.
3939
RUN swift build -c release \
40+
--enable-experimental-prebuilts \
4041
--static-swift-stdlib \
4142
-Xlinker -ljemalloc
4243

@@ -61,7 +62,7 @@ RUN [ -d /build/Resources ] && { mv /build/Resources ./Resources && chmod -R a-w
6162
# ================================
6263
# Run image
6364
# ================================
64-
FROM registry.gitlab.com/finestructure/spi-base:1.2.0
65+
FROM registry.gitlab.com/finestructure/spi-base:1.2.2
6566

6667
# NB sas 2022-09-23: We're not using a dedicated `vapor` user to run the executable, because it
6768
# makes managing the data in the checkouts volume difficult. See

LOCAL_DEVELOPMENT_SETUP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ The trickiest part of this is to ensure the test or app container can connect to
238238
So, in order to run the tests in a Linux container run:
239239

240240
```
241-
docker run --rm -v "$PWD":/host -w /host --add-host=host.docker.internal:host-gateway registry.gitlab.com/finestructure/spi-base:1.2.0 swift test
241+
docker run --rm -v "$PWD":/host -w /host --add-host=host.docker.internal:host-gateway registry.gitlab.com/finestructure/spi-base:1.2.2 swift test
242242
```
243243

244244
Make sure you use the most recent `spi-base` image. You can find the latest image name in the `test-docker` target, which also provides a convenient way to run all all tests in a docker container.

Makefile

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,56 @@ else
2828
endif
2929

3030
build:
31-
swift build --disable-automatic-resolution
31+
swift build --disable-automatic-resolution --enable-experimental-prebuilts
3232

3333
run:
3434
swift run
3535

36-
test: xcbeautify
36+
build-tests: xcbeautify
3737
set -o pipefail \
38-
&& swift test --disable-automatic-resolution \
39-
2>&1 | ./xcbeautify --renderer github-actions
38+
&& swift build --build-tests \
39+
--disable-automatic-resolution \
40+
--enable-experimental-prebuilts \
41+
2>&1 | xcbeautify --renderer github-actions
4042

41-
test-query-performance: xcbeautify
43+
run-tests: xcbeautify
44+
set -o pipefail \
45+
&& swift test --skip-build \
46+
--disable-automatic-resolution \
47+
--enable-experimental-prebuilts \
48+
2>&1 | xcbeautify --renderer github-actions
49+
50+
test: build-tests run-tests
51+
52+
build-query-performance-tests:
53+
set -o pipefail \
54+
&& env RUN_QUERY_PERFORMANCE_TESTS=true \
55+
swift build --build-tests \
56+
--disable-automatic-resolution \
57+
--enable-experimental-prebuilts \
58+
--filter QueryPerformanceTests \
59+
2>&1 | xcbeautify --renderer github-actions
60+
61+
run-query-performance-tests:
4262
set -o pipefail \
4363
&& env RUN_QUERY_PERFORMANCE_TESTS=true \
44-
swift test --disable-automatic-resolution \
64+
swift test --skip-build \
65+
--disable-automatic-resolution \
66+
--enable-experimental-prebuilts \
4567
--filter QueryPerformanceTests \
4668
2>&1 | tee test.log
4769
grep "ℹ️" test.log
48-
grep -v "\] Compiling" test.log | ./xcbeautify --renderer github-actions
70+
grep -v "\] Compiling" test.log | xcbeautify --renderer github-actions
71+
72+
test-query-performance: build-query-performance-tests run-query-performance-tests
4973

5074
test-fast:
5175
@echo Skipping image snapshot tests
5276
@echo Running without --sanitize=thread
5377
swift test --disable-automatic-resolution
5478

5579
xcbeautify:
56-
rm -rf .build/checkouts/xcbeautify
57-
git clone https://github.com/cpisciotta/xcbeautify.git .build/checkouts/xcbeautify
58-
cd .build/checkouts/xcbeautify && git checkout 2.25.1 && make build
59-
binpath=`cd .build/checkouts/xcbeautify && swift build -c release --show-bin-path` && ln -sf $$binpath/xcbeautify
80+
command -v xcbeautify
6081

6182
docker-build: version
6283
docker build -t $(DOCKER_IMAGE):$(VERSION) .
@@ -68,7 +89,7 @@ test-docker:
6889
@# run tests inside a docker container
6990
docker run --rm -v "$(PWD)":/host -w /host \
7091
--add-host=host.docker.internal:host-gateway \
71-
registry.gitlab.com/finestructure/spi-base:1.2.0 \
92+
registry.gitlab.com/finestructure/spi-base:1.2.2 \
7293
make test
7394

7495
test-e2e: db-reset reconcile ingest analyze

Tests/AppTests/QueryPerformanceTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ struct QueryPerformanceTests {
180180
JOIN versions v ON v.package_id = p.id
181181
WHERE v.reference ->> 'branch' = r.default_branch
182182
""")
183-
try await assertQueryPerformance(query, expectedCost: 150_000, variation: 5000)
183+
try await assertQueryPerformance(query, expectedCost: 160_000, variation: 5000)
184184
}
185185
}
186186

0 commit comments

Comments
 (0)