CI: Use caching for nix

This commit is contained in:
Nikos Papadakis 2023-10-12 16:40:38 +03:00
parent e8a6ebafc2
commit 2955f68562
Signed by untrusted user who does not match committer: nikos
GPG key ID: 78871F9905ADFF02
2 changed files with 17 additions and 8 deletions

View file

@ -1,7 +1,7 @@
depends_on: #depends_on:
- build # - build
- test # - test
- lint # - lint
when: when:
- event: push - event: push
@ -17,9 +17,15 @@ steps:
build: build:
image: nixos/nix:latest image: nixos/nix:latest
commands: commands:
- nix --extra-experimental-features "nix-command flakes" build ".#agent.${BUILD_TARGET}" - export AWS_ACCESS_KEY_ID="$${R2_CACHE_ACCESS_KEY}"
- export AWS_SECRET_ACCESS_KEY="$${R2_CACHE_SECRET_KEY}"
- echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
- echo "substituters = s3://prymn-cache?endpoint=75178f9eca227dea51b3db4db2c15a5a.r2.cloudflarestorage.com&region=auto https://cache.nixos.org/" >> /etc/nix/nix.conf
- nix build -L ".#agent.${BUILD_TARGET}"
- mkdir -p "dist/${BUILD_TARGET}-unknown-linux-musl" - mkdir -p "dist/${BUILD_TARGET}-unknown-linux-musl"
- cp result/bin/prymn_agent "dist/${BUILD_TARGET}-unknown-linux-musl/" - cp result/bin/prymn_agent "dist/${BUILD_TARGET}-unknown-linux-musl/"
- nix copy --to 's3://prymn-cache?endpoint=75178f9eca227dea51b3db4db2c15a5a.r2.cloudflarestorage.com&region=auto' ".#agent.${BUILD_TARGET}"
secrets: [ R2_CACHE_ACCESS_KEY, R2_CACHE_SECRET_KEY ]
release: release:
image: woodpeckerci/plugin-s3 image: woodpeckerci/plugin-s3

View file

@ -5,8 +5,7 @@
let let
craneLib = (crane.mkLib pkgs).overrideToolchain pkgs.rustToolchain; craneLib = (crane.mkLib pkgs).overrideToolchain pkgs.rustToolchain;
buildInputs = [ pkgs.protobuf ]; nativeBuildInputs = [ pkgs.protobuf ];
doCheck = false;
src = pkgs.lib.cleanSourceWith { src = pkgs.lib.cleanSourceWith {
src = craneLib.path ../.; src = craneLib.path ../.;
filter = path: type: filter = path: type:
@ -15,8 +14,12 @@ let
}; };
in in
craneLib.buildPackage { craneLib.buildPackage {
inherit src doCheck buildInputs; inherit src nativeBuildInputs;
pname = "prymn_agent";
version = "0.1.0";
doCheck = false; # FIXME: Tests need to run on the native architecture
strictDeps = true;
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static -C linker=rust-lld"; CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static -C linker=rust-lld";
CARGO_BUILD_TARGET = buildTarget; CARGO_BUILD_TARGET = buildTarget;
} }