Skip to content

Commit 96ef0e1

Browse files
committed
*: configure nix binary cache
Add a [nix binary cache using S3 as the backend](https://nix.dev/manual/nix/2.25/store/types/s3-binary-cache-store) for CI builds. This shaves about 3m30s off each CI job.
1 parent ce8f53c commit 96ef0e1

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

ci/docker/entrypoint.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
# NB: Only our CI agents push to this cache but we don't have PKI (e.g.
4+
# signing) setup for them.
5+
## So we mark the cache as trusted to skip signature verifications.
6+
CACHE="s3://redpanda-nix-cache-k8s-m6id12xlarge?region=us-west-2&trusted=true"
7+
8+
nix develop --option extra-substituters "$CACHE" --impure --command "$@"
9+
EXIT_CODE="$?"
10+
11+
echo "--- Pushing to :nix: cache"
12+
nix copy --to "$CACHE" .#devshell
13+
14+
exit "$EXIT_CODE"

ci/docker/nix.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ RUN echo 'experimental-features = nix-command flakes' >> /etc/nix/nix.conf \
1818
# easier to disable this check entirely:
1919
&& git config --global --add safe.directory '*'
2020

21-
ENTRYPOINT ["nix", "develop", "--impure", "--command"]
21+
COPY ci/docker/entrypoint.sh /
22+
23+
ENTRYPOINT ["bash", "/entrypoint.sh"]

ci/scripts/run-in-nix-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fi
3333
set -e
3434

3535
# BUILDKITE environment variables are used by `buildkite-agent` cli to upload artifact
36-
printenv | grep '^BUILDKITE.*=' > env-file-for-buildkite
36+
printenv | { grep '^BUILDKITE.*=' || true; } > env-file-for-buildkite
3737

3838
# Build the base image and grab the SHA.
3939
IMAGE_SHA=$(docker build --quiet -f ./ci/docker/nix.Dockerfile .)

flake.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
{
3737
formatter = pkgs.nixpkgs-fmt;
3838

39+
# Make it possible to reference the devshell context from standard
40+
# nix commands. e.g. nix copy .#devshell.
41+
packages.devshell = self'.devShells.default;
42+
3943
devshells.default = {
4044
env = [
4145
{ name = "GOROOT"; value = "${pkgs.go_1_24}/share/go"; }

taskfiles/ci.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ tasks:
99
- task: set-aio-max
1010
- task: set-inotify-watches
1111
- task: set-inotify-instances
12-
- task: configure-git-private-repo
1312
- cmd: "mkdir -p {{.SRC_DIR}}/artifacts"
14-
# Fetch the release branches for our git based linters.
15-
- cmd: git fetch origin release/v2.4.x
1613

1714
lint:
1815
cmds:
@@ -24,6 +21,7 @@ tasks:
2421
test:unit:
2522
cmds:
2623
- defer: 'buildkite-agent artifact upload "{{.SRC_DIR}}/artifacts/*"'
24+
- 'echo "--- Running unit tests"'
2725
- task: :test:unit
2826
vars:
2927
GO_TEST_RUNNER: 'gotestsum --junitfile=artifacts/unit-tests.xml --'
@@ -33,6 +31,7 @@ tasks:
3331
cmds:
3432
- defer: 'kind delete clusters --all'
3533
- defer: 'buildkite-agent artifact upload "{{.SRC_DIR}}/artifacts/*"'
34+
- 'echo "--- Running integration tests"'
3635
- task: :test:integration
3736
vars:
3837
GO_TEST_RUNNER: 'gotestsum --junitfile=artifacts/integration-tests.xml --'
@@ -42,6 +41,7 @@ tasks:
4241
cmds:
4342
- defer: 'kind delete clusters --all'
4443
- defer: 'buildkite-agent artifact upload "{{.SRC_DIR}}/artifacts/*"'
44+
- 'echo "--- Running acceptance tests"'
4545
- task: :test:acceptance
4646
vars:
4747
GO_TEST_RUNNER: 'gotestsum --junitfile=artifacts/acceptance-tests.xml --'
@@ -66,16 +66,6 @@ tasks:
6666
vars:
6767
KUTTL_CONFIG_FILE: kuttl-v2-test.yaml
6868

69-
configure-git-private-repo:
70-
internal: true
71-
env:
72-
GITHUB_TOKEN:
73-
sh: echo "${GITHUB_TOKEN:-$GITHUB_API_TOKEN}"
74-
cmds:
75-
- git config --global url."https://$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"
76-
preconditions:
77-
- test -n "$GITHUB_API_TOKEN" || test -n "$GITHUB_TOKEN"
78-
7969
run-kuttl-tests:
8070
cmds:
8171
- defer:

0 commit comments

Comments
 (0)