From 682bccb6eeaa6a6116bc9b2b518bd5f2eca66883 Mon Sep 17 00:00:00 2001 From: Timo Beckers Date: Mon, 26 Sep 2022 12:26:43 +0200 Subject: [PATCH] Semaphore: remove manual Go installation, expedite 'cache restore' 'sem-version' apparently installs Go, so rely on it instead of isntalling Go manually. Execute 'cache restore' after 'checkout' (since it scans for go.mod), but before 'go install' to avoid tar errors unpacking the cache archive: ``` Unpacking command failed: tar: /home/semaphore/go/pkg/mod/github.com/jonboulle/clockwork@v0.2.2/.github/workflows/ci.yml: Cannot open: File exists tar: /home/semaphore/go/pkg/mod/github.com/jonboulle/clockwork@v0.2.2/.github/workflows/.editorconfig: Cannot open: File exists tar: /home/semaphore/go/pkg/mod/github.com/jonboulle/clockwork@v0.2.2/ticker.go: Cannot open: File exists ... ``` 'go install' does something that changes the ownership of go/pkg/mod, tripping up tar. Since 'go install' doesn't need to be run outside of a Go module like 'go get' did when using it to install tool binaries, it can safely be run after checkout. Signed-off-by: Timo Beckers --- .semaphore/semaphore.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 3d87f9053..3235c73ac 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -23,14 +23,13 @@ blocks: prologue: commands: - sudo sh -c 'swapoff -a && fallocate -l 2G /swapfile && chmod 0600 /swapfile && mkswap /swapfile && swapon /swapfile' - - sudo mkdir -p /usr/local/golang/1.19 && curl -fL "https://go.dev/dl/go1.19.1.linux-amd64.tar.gz" | sudo tar -xz -C /usr/local/golang/1.19 - - sem-version go 1.19 + - sem-version go 1.19.1 - export PATH="$PATH:$(go env GOPATH)/bin" - - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.48.0 - - go install gotest.tools/gotestsum@v1.8.1 - checkout - cache restore - go mod tidy + - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.48.0 + - go install gotest.tools/gotestsum@v1.8.1 - sudo pip3 install https://github.com/amluto/virtme/archive/beb85146cd91de37ae455eccb6ab67c393e6e290.zip - sudo apt-get update - sudo apt-get install -y --no-install-recommends qemu-system-x86 clang-9 llvm-9