One of my build steps is a custom script:
bash test/test.sh
The script itself sits in the source code and launches the testing:
cd test && go test github.com/geniot/blaze-test/src -json
I use run step within container golang:latest, I've also tried the Run in Docker feature.
But the problem is that this configuration launches the download of all go dependencies for each run. Which takes around 10-15 seconds (my guess). The whole step takes 23 seconds.
22:48:10 Step 4/6: Test Unstable (test.blaze.ad) (Command Line)
22:48:10 Running step within container golang:latest
22:48:10 Created container 60a19864abc1...
22:48:11 Starting: /bin/sh -c . /opt/buildagent/temp/agentTmp/docker-wrapper-env-export-13473230305602170975.sh && docker exec -w /opt/buildagent/work/a993f8719008f409 60a19864abc17f5fb5927176fb150f5f7f85559b599e14d8b657bc2e15109d78 /bin/sh -c /opt/buildagent/temp/agentTmp/docker-shell-script-1481671475381782727.sh
22:48:11 in directory: /opt/buildagent/work/a993f8719008f409
22:48:11 go: downloading github.com/sirupsen/logrus v1.9.3
22:48:11 go: downloading github.com/golang-jwt/jwt/v5 v5.3.0
22:48:11 go: downloading github.com/num30/config v0.1.3
...
Is there a way to avoid this downloading? I've noticed that a simple docker build of a Go project uses cached results if the source code has not changed:
22:48:09 #21 [backend 5/10] RUN go mod download
22:48:09 #21 CACHED
22:48:09 #23 [backend 10/10] RUN go build -o /blaze github.com/geniot/blaze/src
22:48:09 #23 CACHED
RUN --mount=type=cacheoption, which will provide a persistent cache for individual files such as downloaded packages. Does adding a similar option to theRUN test/test.shline help your setup?go test .and see if it works. If it passes, thendocker buildyour image.