From cc7758c84febe3acf31e11b73a15216689c5ff3b Mon Sep 17 00:00:00 2001 From: Victor Fuentes Date: Fri, 6 Dec 2024 18:16:03 -0800 Subject: [PATCH] [ci] use s1-goval-nixos --- .semaphore/semaphore.yml | 14 +++++--------- Makefile | 4 ++-- nix/default.nix | 3 ++- nix/goCache/default.nix | 16 ++++++++++++++++ nix/{upm => goCache}/imported-packages | 0 nix/upm/default.nix | 21 ++------------------- 6 files changed, 27 insertions(+), 31 deletions(-) create mode 100644 nix/goCache/default.nix rename nix/{upm => goCache}/imported-packages (100%) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 13882c5a..ca65a515 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -3,7 +3,7 @@ version: v1.0 name: UPM agent: machine: - type: s1-goval + type: s1-goval-nixos global_job_config: env_vars: @@ -13,8 +13,7 @@ global_job_config: commands: - checkout - git switch --detach - - export PATH="/tmp:$PATH" - - source ./.semaphore/install_nix.sh + - eval "$(nix print-dev-env)" blocks: - name: test @@ -23,7 +22,8 @@ blocks: jobs: - name: test-suite commands: - - nix develop -c nix shell -c make test-suite + - export PATH="$(nix build . --no-link --print-out-paths)/bin:$PATH" + - make test-suite epilogue: commands: - test-results publish junit.xml @@ -35,11 +35,7 @@ blocks: - name: golang lint commands: - make generated - - cache restore golangci-lint - - >- - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh - | sh -s -- -b /tmp v1.55.2 - - /tmp/golangci-lint run + - golangci-lint run after_pipeline: task: diff --git a/Makefile b/Makefile index 3bba3f2e..3418c265 100644 --- a/Makefile +++ b/Makefile @@ -99,7 +99,7 @@ test-suite: go run gotest.tools/gotestsum --junitfile ./junit.xml ./test-suite else test-suite: - nix develop -c nix shell -c go test -run $(GO_TEST_RUN_OPTS) ./test-suite + go test -run $(GO_TEST_RUN_OPTS) ./test-suite # I don't have a great name for these. The cases are as follows: # make test-python3 # This runs inside nix develop and gates test suite @@ -112,7 +112,7 @@ test-suite: # # two modes. It isn't very useful when run directly, # # since it doesn't know where upm or the PYPI_MAP_DB are. test-%: - nix develop -c nix shell -c make wrapped-$@ + make wrapped-$@ unwrapped-test-%: label="$@"; \ diff --git a/nix/default.nix b/nix/default.nix index 17b073e5..e9336654 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -12,5 +12,6 @@ in rec { default = upm; devShell = pkgs.callPackage ./devshell {nix-editor = nix-editor-pkg;}; fmt = pkgs.callPackage ./fmt {}; - upm = pkgs.callPackage ./upm {inherit rev; inherit buildGoCache;}; + upm = pkgs.callPackage ./upm {inherit rev; inherit goCache;}; + goCache = pkgs.callPackage ./goCache {inherit buildGoCache;}; } diff --git a/nix/goCache/default.nix b/nix/goCache/default.nix new file mode 100644 index 00000000..258569ab --- /dev/null +++ b/nix/goCache/default.nix @@ -0,0 +1,16 @@ +{ + buildGoCache, + runCommand, +}: +buildGoCache { + # keep this up-to-date in CI with: + # $ nix run 'github:numtide/build-go-cache#get-external-imports' -- ./. imported-packages + importPackagesFile = ./imported-packages; + # FIXME: Somehow we get cache invalidation everytime if we don't do this, also it uses a source filter + src = runCommand "go-mod" {} '' + install -D ${../../go.mod} $out/go.mod + install -D ${../../go.sum} $out/go.sum + ''; + vendorHash = "sha256-vHWl1t/tZ1siHJpxazIzkD3FSYokPm7KZVnM+X02O9Q="; + proxyVendor = true; +} diff --git a/nix/upm/imported-packages b/nix/goCache/imported-packages similarity index 100% rename from nix/upm/imported-packages rename to nix/goCache/imported-packages diff --git a/nix/upm/default.nix b/nix/upm/default.nix index 1584049a..ec995aa6 100644 --- a/nix/upm/default.nix +++ b/nix/upm/default.nix @@ -2,25 +2,8 @@ buildGoModule, rev, makeWrapper, - buildGoCache, - runCommand, + goCache, }: -let - vendorHash = "sha256-vHWl1t/tZ1siHJpxazIzkD3FSYokPm7KZVnM+X02O9Q="; - - goCache = buildGoCache { - # keep this up-to-date in CI with: - # $ nix run 'github:numtide/build-go-cache#get-external-imports' -- ./. imported-packages - importPackagesFile = ./imported-packages; - # FIXME: Somehow we get cache invalidation everytime if we don't do this, also it uses a source filter - src = runCommand "go-mod" {} '' - install -D ${../../go.mod} $out/go.mod - install -D ${../../go.sum} $out/go.sum - ''; - inherit vendorHash; - proxyVendor = true; - }; -in buildGoModule rec { pname = "upm"; version = rev; @@ -60,7 +43,7 @@ buildGoModule rec { --set PYPI_MAP_DB "$out/pypi_map.sqlite" ''; - inherit vendorHash; + inherit (goCache) vendorHash; proxyVendor = true; # we only support proxyVendor with buildGoCache just now doCheck = false;