Skip to content

Commit be37473

Browse files
committed
ci: daggerize go.yml pipeline
Signed-off-by: Marcos Lilljedahl <[email protected]>
1 parent f08b10c commit be37473

File tree

10 files changed

+279
-77
lines changed

10 files changed

+279
-77
lines changed

.github/workflows/go.yml

+61-66
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,61 @@
1-
---
2-
name: Go
3-
on:
4-
pull_request:
5-
push:
6-
branches:
7-
- main
8-
- "release-*"
9-
10-
concurrency:
11-
group: ${{ github.workflow }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
12-
cancel-in-progress: true
13-
14-
# Minimal permissions to be inherited by any job that don't declare it's own permissions
15-
permissions:
16-
contents: read
17-
18-
jobs:
19-
supportedVersions:
20-
name: Fetch supported Go versions
21-
runs-on: ubuntu-latest
22-
outputs:
23-
supported_versions: ${{ steps.matrix.outputs.supported_versions }}
24-
steps:
25-
- name: Checkout code
26-
uses: actions/checkout@v4
27-
- name: Read supported_go_versions.txt
28-
id: matrix
29-
run: |
30-
versions=$(cat supported_go_versions.txt)
31-
matrix="[$(echo "$versions" | sed 's/\(.*\)/"\1"/' | paste -s -d,)]"
32-
echo "supported_versions=$matrix" >> $GITHUB_OUTPUT
33-
34-
test:
35-
name: Tests
36-
runs-on: ubuntu-latest
37-
needs: supportedVersions
38-
39-
strategy:
40-
matrix:
41-
go_version: ${{ fromJSON(needs.supportedVersions.outputs.supported_versions) }}
42-
43-
steps:
44-
- name: Checkout code
45-
uses: actions/[email protected]
46-
47-
- name: Set up Go ${{ matrix.go_version }}
48-
uses: actions/[email protected]
49-
with:
50-
go-version: ${{ matrix.go_version }}
51-
52-
- name: Cache Go modules
53-
id: cache
54-
uses: actions/cache@v4
55-
with:
56-
path: ~/go/pkg/mod
57-
key: v1-go${{ matrix.go_version }}
58-
59-
- name: Run tests and check license
60-
run: make check_license test
61-
env:
62-
CI: true
63-
64-
- name: Run style and unused
65-
if: ${{ matrix.go_version == '1.20' }}
66-
run: make style unused
1+
---
2+
name: Go
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- "release-*"
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
12+
cancel-in-progress: true
13+
14+
# Minimal permissions to be inherited by any job that don't declare it's own permissions
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
20+
supportedVersions:
21+
name: Fetch supported Go versions
22+
runs-on: ubuntu-latest
23+
outputs:
24+
supported_versions: ${{ steps.matrix.outputs.supported_versions }}
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
- name: Read supported_go_versions.txt
29+
id: matrix
30+
run: |
31+
versions=$(cat supported_go_versions.txt)
32+
matrix="[$(echo "$versions" | sed 's/\(.*\)/"\1"/' | paste -s -d,)]"
33+
echo "supported_versions=$matrix" >> $GITHUB_OUTPUT
34+
35+
test:
36+
name: Tests
37+
runs-on: ubuntu-latest
38+
needs: supportedVersions
39+
40+
strategy:
41+
matrix:
42+
go_version: ${{ fromJSON(needs.supportedVersions.outputs.supported_versions) }}
43+
44+
steps:
45+
- name: Checkout code
46+
uses: actions/[email protected]
47+
48+
- name: Run tests and check license
49+
uses: dagger/dagger-for-github@v5
50+
with:
51+
version: "latest"
52+
verb: call
53+
args: -vvv --src . make --go-version ${{matrix.go_version}} --args 'check_license test'
54+
55+
- name: Run style and unused
56+
uses: dagger/dagger-for-github@v5
57+
if: ${{ matrix.go_version == '1.20' }}
58+
with:
59+
version: "latest"
60+
verb: call
61+
args: -vvv --src . make --args 'check_license test'

.github/workflows/golangci-lint.yml

+4-10
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,9 @@ jobs:
2525
steps:
2626
- name: Checkout repository
2727
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
28-
- name: Install Go
29-
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
30-
with:
31-
go-version: 1.22.x
32-
- name: Install snmp_exporter/generator dependencies
33-
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
34-
if: github.repository == 'prometheus/snmp_exporter'
3528
- name: Lint
36-
uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1
29+
uses: dagger/dagger-for-github@v5
3730
with:
38-
args: --verbose
39-
version: v1.59.0
31+
version: "latest"
32+
verb: call
33+
args: -vvv --src . make --args lint

.golangci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ run:
44
skip-files:
55
# Skip autogenerated files.
66
- ^.*\.(pb|y)\.go$
7+
- dagger/dagger.gen.go
8+
skip-dirs:
9+
- dagger/internal
10+
711

812
output:
913
sort-results: true

Makefile.common

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ common-style:
121121
.PHONY: common-check_license
122122
common-check_license:
123123
@echo ">> checking license header"
124-
@licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \
124+
@licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*' ! -path './dagger/internal/*') ; do \
125125
awk 'NR<=3' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \
126126
done); \
127127
if [ -n "$${licRes}" ]; then \

dagger.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "client_golang",
3+
"sdk": "go",
4+
"dependencies": [
5+
{
6+
"name": "golang",
7+
"source": "github.com/kpenfound/dagger-modules/golang@fd1a6e75721454d8ee3bcb0bd1a94d6bb4be1737"
8+
}
9+
],
10+
"source": "dagger",
11+
"engineVersion": "v0.11.6"
12+
}

dagger/.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/dagger.gen.go linguist-generated
2+
/internal/dagger/** linguist-generated
3+
/internal/querybuilder/** linguist-generated
4+
/internal/telemetry/** linguist-generated

dagger/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/dagger.gen.go
2+
/internal/dagger
3+
/internal/querybuilder
4+
/internal/telemetry

dagger/go.mod

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module dagger
2+
3+
go 1.21.7
4+
5+
require (
6+
github.com/99designs/gqlgen v0.17.44
7+
github.com/Khan/genqlient v0.7.0
8+
github.com/vektah/gqlparser/v2 v2.5.11
9+
go.opentelemetry.io/otel v1.26.0
10+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.26.0
11+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.26.0
12+
go.opentelemetry.io/otel/sdk v1.26.0
13+
go.opentelemetry.io/otel/trace v1.26.0
14+
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
15+
golang.org/x/sync v0.7.0
16+
google.golang.org/grpc v1.63.2
17+
)
18+
19+
require (
20+
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
21+
github.com/go-logr/logr v1.4.1 // indirect
22+
github.com/go-logr/stdr v1.2.2 // indirect
23+
github.com/google/uuid v1.6.0 // indirect
24+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
25+
github.com/sosodev/duration v1.2.0 // indirect
26+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 // indirect
27+
go.opentelemetry.io/otel/metric v1.26.0 // indirect
28+
go.opentelemetry.io/proto/otlp v1.2.0 // indirect
29+
golang.org/x/net v0.23.0 // indirect
30+
golang.org/x/sys v0.19.0 // indirect
31+
golang.org/x/text v0.14.0 // indirect
32+
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
33+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
34+
google.golang.org/protobuf v1.33.0 // indirect
35+
)

dagger/go.sum

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
github.com/99designs/gqlgen v0.17.44 h1:OS2wLk/67Y+vXM75XHbwRnNYJcbuJd4OBL76RX3NQQA=
2+
github.com/99designs/gqlgen v0.17.44/go.mod h1:UTCu3xpK2mLI5qcMNw+HKDiEL77it/1XtAjisC4sLwM=
3+
github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w=
4+
github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM=
5+
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
6+
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
7+
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
8+
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
9+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
10+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
11+
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
12+
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
13+
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
14+
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
15+
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
16+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
17+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
18+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
19+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
20+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is=
21+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
22+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
23+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
24+
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
25+
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
26+
github.com/sosodev/duration v1.2.0 h1:pqK/FLSjsAADWY74SyWDCjOcd5l7H8GSnnOGEB9A1Us=
27+
github.com/sosodev/duration v1.2.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
28+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
29+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
30+
github.com/vektah/gqlparser/v2 v2.5.11 h1:JJxLtXIoN7+3x6MBdtIP59TP1RANnY7pXOaDnADQSf8=
31+
github.com/vektah/gqlparser/v2 v2.5.11/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc=
32+
go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs=
33+
go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4=
34+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 h1:1u/AyyOqAWzy+SkPxDpahCNZParHV8Vid1RnI2clyDE=
35+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0/go.mod h1:z46paqbJ9l7c9fIPCXTqTGwhQZ5XoTIsfeFYWboizjs=
36+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.26.0 h1:Waw9Wfpo/IXzOI8bCB7DIk+0JZcqqsyn1JFnAc+iam8=
37+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.26.0/go.mod h1:wnJIG4fOqyynOnnQF/eQb4/16VlX2EJAHhHgqIqWfAo=
38+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.26.0 h1:1wp/gyxsuYtuE/JFxsQRtcCDtMrO2qMvlfXALU5wkzI=
39+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.26.0/go.mod h1:gbTHmghkGgqxMomVQQMur1Nba4M0MQ8AYThXDUjsJ38=
40+
go.opentelemetry.io/otel/metric v1.26.0 h1:7S39CLuY5Jgg9CrnA9HHiEjGMF/X2VHvoXGgSllRz30=
41+
go.opentelemetry.io/otel/metric v1.26.0/go.mod h1:SY+rHOI4cEawI9a7N1A4nIg/nTQXe1ccCNWYOJUrpX4=
42+
go.opentelemetry.io/otel/sdk v1.26.0 h1:Y7bumHf5tAiDlRYFmGqetNcLaVUZmh4iYfmGxtmz7F8=
43+
go.opentelemetry.io/otel/sdk v1.26.0/go.mod h1:0p8MXpqLeJ0pzcszQQN4F0S5FVjBLgypeGSngLsmirs=
44+
go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA=
45+
go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0=
46+
go.opentelemetry.io/proto/otlp v1.2.0 h1:pVeZGk7nXDC9O2hncA6nHldxEjm6LByfA2aN8IOkz94=
47+
go.opentelemetry.io/proto/otlp v1.2.0/go.mod h1:gGpR8txAl5M03pDhMC79G6SdqNV26naRm/KDsgaHD8A=
48+
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
49+
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
50+
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
51+
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
52+
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
53+
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
54+
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
55+
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
56+
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
57+
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
58+
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
59+
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
60+
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY=
61+
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo=
62+
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0=
63+
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8=
64+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4=
65+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
66+
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
67+
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
68+
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
69+
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
70+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
71+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

dagger/main.go

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright 2024 The Prometheus Authors
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
// A minimal example of how to include Prometheus instrumentation.
15+
16+
package main
17+
18+
import (
19+
"context"
20+
"strings"
21+
22+
"golang.org/x/sync/errgroup"
23+
)
24+
25+
type ClientGolang struct {
26+
Source *Directory // +private
27+
}
28+
29+
func New(src *Directory) *ClientGolang {
30+
return &ClientGolang{Source: src}
31+
}
32+
33+
// runs `make` with the given arguments
34+
func (m *ClientGolang) Make(
35+
// +optional
36+
args string,
37+
// +default="1.20"
38+
goVersion string,
39+
// +optional
40+
env []string,
41+
) (string, error) {
42+
return dag.Golang().
43+
Base(goVersion).
44+
Container().
45+
WithMountedDirectory("/src", m.Source).
46+
WithWorkdir("/src").
47+
WithMountedCache("/go/bin", dag.CacheVolume("gobincache")).
48+
WithExec([]string{"sh", "-c", "make " + args}).
49+
Stdout(context.Background())
50+
}
51+
52+
// runs `make` with the given arguments for all supported go versions
53+
func (m *ClientGolang) MakeAll(
54+
ctx context.Context,
55+
// +optional,
56+
args string,
57+
) error {
58+
c, err := m.Source.File("supported_go_versions.txt").Contents(ctx)
59+
if err != nil {
60+
return err
61+
}
62+
goVersions := strings.Split(c, "\n")
63+
64+
eg := new(errgroup.Group)
65+
66+
for _, version := range goVersions {
67+
version := version
68+
if len(version) > 0 {
69+
eg.Go(func() error {
70+
_, err := dag.Golang().
71+
Base(version).
72+
Container().
73+
WithMountedDirectory("/src", m.Source).
74+
WithWorkdir("/src").
75+
WithMountedCache("/go/bin", dag.CacheVolume("gobincache")).
76+
WithExec([]string{"sh", "-c", "make " + args}).Sync(ctx)
77+
return err
78+
})
79+
}
80+
}
81+
82+
return eg.Wait()
83+
}

0 commit comments

Comments
 (0)