Skip to content

Commit c6273e0

Browse files
authored
test: run linux package tests nightly against latest contrib main [new] (open-telemetry#762)
* previous commits * release pipeline fixes * fixes after rebasing Signed-off-by: Moritz Wiesinger <[email protected]> * trigger build * downgrade ubuntu version back to 22.04 Signed-off-by: Moritz Wiesinger <[email protected]> * try to restore state before rebase Signed-off-by: Moritz Wiesinger <[email protected]> * run tests to ensure that everything works Signed-off-by: Moritz Wiesinger <[email protected]> * revert after successful testing Signed-off-by: Moritz Wiesinger <[email protected]> --------- Signed-off-by: Moritz Wiesinger <[email protected]>
1 parent 7892e55 commit c6273e0

12 files changed

+262
-57
lines changed

.github/workflows/base-ci-goreleaser.yaml

+72-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ on:
1212
goarch:
1313
required: true
1414
type: string
15+
nightly:
16+
required: false
17+
type: boolean
18+
default: false
19+
description: "Set to true to fetch latest otelcol-contrib main branch version instead of building the version in this repo"
1520

1621
env:
1722
# renovate: datasource=github-tags depName=goreleaser-pro packageName=goreleaser/goreleaser-pro
@@ -64,9 +69,75 @@ jobs:
6469
go-version: '1.23'
6570
check-latest: true
6671

67-
- name: Generate the sources
72+
- name: Create artifacts directory to store build artifacts
73+
if: inputs.distribution == 'otelcol-contrib'
74+
run: mkdir -p distributions/otelcol-contrib/artifacts
75+
76+
- name: "[Nightly] Get latest finished run ID from contrib repo build-and-test"
77+
id: get-run-id
78+
if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux'
79+
env:
80+
GH_TOKEN: ${{ github.token }}
81+
run: |
82+
run_id=$(gh run list \
83+
--branch main \
84+
--workflow build-and-test \
85+
--repo open-telemetry/opentelemetry-collector-contrib \
86+
--limit 1 \
87+
--status success \
88+
--json databaseId \
89+
--jq '.[0].databaseId' \
90+
)
91+
echo "Found run ID: $run_id"
92+
echo "run_id=$run_id" >> "$GITHUB_OUTPUT"
93+
94+
- name: "[Nightly] Create sub-directory for otelcol-contrib nightly build"
95+
if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux'
96+
run: mkdir -p distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1
97+
98+
- name: "[Nightly] Download built otelcol-contrib artifact from contrib repo"
99+
if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux'
100+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
101+
with:
102+
name: collector-binaries-linux-amd64
103+
repository: open-telemetry/opentelemetry-collector-contrib
104+
github-token: ${{ secrets.GITHUB_TOKEN }}
105+
run-id: ${{ steps.get-run-id.outputs.run_id }}
106+
107+
- name: "[Nightly] Move downloaded artifact"
108+
if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux'
109+
run: mv otelcontribcol_linux_amd64 distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1/otelcol-contrib
110+
111+
- name: Generate the sources for ${{ inputs.distribution }}
112+
if: inputs.nightly != true
113+
env:
114+
DISTRIBUTIONS: ${{ inputs.distribution }}
68115
run: make generate-sources
69116

117+
# otelcol-contrib is built in a separate stage
118+
- name: Build ${{ inputs.distribution }}
119+
if: inputs.distribution == 'otelcol-contrib' && inputs.nightly != true
120+
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
121+
with:
122+
distribution: goreleaser-pro
123+
version: ${{ env.GORELEASER_PRO_VERSION }}
124+
workdir: distributions/otelcol-contrib
125+
args: --snapshot --clean --timeout 2h --split --config .goreleaser-build.yaml
126+
env:
127+
GOOS: ${{ matrix.GOOS }}
128+
GOARCH: ${{ matrix.GOARCH }}
129+
GOARM: 7 # Default is 6
130+
GOAMD64: v1
131+
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
132+
133+
- name: Move built artifacts
134+
if: inputs.distribution == 'otelcol-contrib' && inputs.nightly != true
135+
run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/
136+
137+
- name: Show built or downloaded content
138+
if: inputs.distribution == 'otelcol-contrib'
139+
run: ls -laR distributions/otelcol-contrib/artifacts
140+
70141
- name: Run GoReleaser for ${{ inputs.distribution }}
71142
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
72143
with:

.github/workflows/base-release.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,36 @@ jobs:
8484
run: |
8585
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
8686
87+
- name: Create artifacts directory to store build artifacts
88+
if: inputs.distribution == 'otelcol-contrib'
89+
run: mkdir -p distributions/otelcol-contrib/artifacts
90+
91+
# otelcol-contrib is built in a separate stage
92+
- name: Build ${{ inputs.distribution }}
93+
if: inputs.distribution == 'otelcol-contrib'
94+
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
95+
with:
96+
distribution: goreleaser-pro
97+
version: ${{ env.GORELEASER_PRO_VERSION }}
98+
workdir: distributions/${{ inputs.distribution }}
99+
args: release --clean --split --timeout 2h --config .goreleaser-build.yaml --release-header-tmpl=../../.github/release-template.md
100+
env:
101+
GOOS: ${{ matrix.GOOS }}
102+
GOARCH: ${{ matrix.GOARCH }}
103+
GOARM: 7 # Default is 6
104+
GOAMD64: v1
105+
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
106+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
107+
COSIGN_YES: true
108+
109+
- name: Move built artifacts
110+
if: inputs.distribution == 'otelcol-contrib'
111+
run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/
112+
113+
- name: Show built or downloaded content
114+
if: inputs.distribution == 'otelcol-contrib'
115+
run: ls -laR distributions/otelcol-contrib/artifacts
116+
87117
- uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
88118
with:
89119
distribution: goreleaser-pro

.github/workflows/ci-goreleaser-contrib.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
package-tests:
3737
name: Package tests
3838
needs: check-goreleaser
39-
uses: ./.github/workflows/package-tests.yaml
39+
uses: ./.github/workflows/base-package-tests.yaml
4040
with:
4141
distribution: otelcol-contrib
4242
type: '[ "deb", "rpm" ]'

.github/workflows/ci-goreleaser-core.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
package-tests:
3737
name: Package tests
3838
needs: check-goreleaser
39-
uses: ./.github/workflows/package-tests.yaml
39+
uses: ./.github/workflows/base-package-tests.yaml
4040
with:
4141
distribution: otelcol
4242
type: '[ "deb", "rpm" ]'

.github/workflows/package-test.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Package Tests - Contrib
2+
3+
on:
4+
schedule:
5+
- cron: "0 2 * * *" # every day at 2am UTC
6+
7+
jobs:
8+
check-goreleaser:
9+
name: Build - Contrib - GoReleaser
10+
uses: ./.github/workflows/base-ci-goreleaser.yaml
11+
with:
12+
distribution: otelcol-contrib
13+
goos: '[ "linux" ]'
14+
goarch: '[ "amd64" ]'
15+
nightly: true
16+
secrets: inherit
17+
18+
package-tests:
19+
name: Linux Package tests
20+
needs: check-goreleaser
21+
uses: ./.github/workflows/base-package-tests.yaml
22+
with:
23+
distribution: otelcol-contrib
24+
type: '[ "deb", "rpm" ]'

cmd/goreleaser/internal/configure.go

+74-45
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,32 @@ const (
4242
var (
4343
ImagePrefixes = []string{DockerHub, GHCR}
4444
Architectures = []string{"386", "amd64", "arm", "arm64", "ppc64le", "s390x"}
45-
ArmVersions = []string{"7"}
4645
DefaultConfigDists = map[string]bool{CoreDistro: true, ContribDistro: true}
4746
MSIWindowsDists = map[string]bool{CoreDistro: true, ContribDistro: true, OTLPDistro: true}
4847
K8sDockerSkipArchs = map[string]bool{"arm": true, "386": true}
4948
K8sGoos = []string{"linux"}
5049
K8sArchs = []string{"amd64", "arm64", "ppc64le", "s390x"}
5150
)
5251

53-
func Generate(dist string) config.Project {
52+
func GenerateContribBuildOnly(dist string, buildOrRest bool) config.Project {
53+
return config.Project{
54+
ProjectName: "opentelemetry-collector-releases",
55+
Builds: Builds(dist, buildOrRest),
56+
Version: 2,
57+
Monorepo: config.Monorepo{
58+
TagPrefix: "v",
59+
},
60+
}
61+
}
62+
63+
func Generate(dist string, buildOrRest bool) config.Project {
5464
return config.Project{
5565
ProjectName: "opentelemetry-collector-releases",
5666
Checksum: config.Checksum{
5767
NameTemplate: fmt.Sprintf("{{ .ProjectName }}_%v_checksums.txt", dist),
5868
},
5969
Env: []string{"COSIGN_YES=true"},
60-
Builds: Builds(dist),
70+
Builds: Builds(dist, buildOrRest),
6171
Archives: Archives(dist),
6272
MSI: WinPackages(dist),
6373
NFPMs: Packages(dist),
@@ -73,37 +83,41 @@ func Generate(dist string) config.Project {
7383
}
7484
}
7585

76-
func Builds(dist string) []config.Build {
86+
func Builds(dist string, buildOrRest bool) []config.Build {
7787
return []config.Build{
78-
Build(dist),
88+
Build(dist, buildOrRest),
7989
}
8090
}
8191

8292
// Build configures a goreleaser build.
8393
// https://goreleaser.com/customization/build/
84-
func Build(dist string) config.Build {
85-
var goos []string
86-
var archs []string
87-
var ignore []config.IgnoredBuild
88-
var armVersions []string
94+
func Build(dist string, buildOrRest bool) config.Build {
95+
goos := []string{"darwin", "linux", "windows"}
96+
archs := Architectures
97+
98+
if dist == ContribDistro && !buildOrRest {
99+
// only return build config for contrib build file
100+
return config.Build{
101+
ID: dist,
102+
Builder: "prebuilt",
103+
PreBuilt: config.PreBuiltOptions{
104+
Path: "artifacts/otelcol-contrib_{{ .Target }}" +
105+
"/otelcol-contrib{{- if eq .Os \"windows\" }}.exe{{ end }}",
106+
},
107+
Goos: goos,
108+
Goarch: archs,
109+
Goarm: ArmVersions(dist),
110+
Dir: "_build",
111+
Binary: dist,
112+
Ignore: IgnoreBuildCombinations(dist),
113+
}
114+
}
115+
89116
if dist == K8sDistro {
90117
goos = K8sGoos
91118
archs = K8sArchs
92-
ignore = make([]config.IgnoredBuild, 0)
93-
armVersions = make([]string, 0)
94-
} else {
95-
goos = []string{"darwin", "linux", "windows"}
96-
archs = Architectures
97-
ignore = []config.IgnoredBuild{
98-
{Goos: "darwin", Goarch: "386"},
99-
{Goos: "darwin", Goarch: "arm"},
100-
{Goos: "darwin", Goarch: "s390x"},
101-
{Goos: "windows", Goarch: "arm"},
102-
{Goos: "windows", Goarch: "arm64"},
103-
{Goos: "windows", Goarch: "s390x"},
104-
}
105-
armVersions = ArmVersions
106119
}
120+
107121
return config.Build{
108122
ID: dist,
109123
Dir: "_build",
@@ -115,12 +129,33 @@ func Build(dist string) config.Build {
115129
},
116130
Goos: goos,
117131
Goarch: archs,
118-
Goarm: armVersions,
119-
Ignore: ignore,
132+
Goarm: ArmVersions(dist),
133+
Ignore: IgnoreBuildCombinations(dist),
120134
}
121135
}
122136

123-
func Archives(dist string) (r []config.Archive) {
137+
func IgnoreBuildCombinations(dist string) []config.IgnoredBuild {
138+
if dist == K8sDistro {
139+
return nil
140+
}
141+
return []config.IgnoredBuild{
142+
{Goos: "darwin", Goarch: "386"},
143+
{Goos: "darwin", Goarch: "arm"},
144+
{Goos: "darwin", Goarch: "s390x"},
145+
{Goos: "windows", Goarch: "arm"},
146+
{Goos: "windows", Goarch: "arm64"},
147+
{Goos: "windows", Goarch: "s390x"},
148+
}
149+
}
150+
151+
func ArmVersions(dist string) []string {
152+
if dist == K8sDistro {
153+
return nil
154+
}
155+
return []string{"7"}
156+
}
157+
158+
func Archives(dist string) []config.Archive {
124159
return []config.Archive{
125160
Archive(dist),
126161
}
@@ -138,7 +173,7 @@ func Archive(dist string) config.Archive {
138173

139174
func WinPackages(dist string) []config.MSI {
140175
if _, ok := MSIWindowsDists[dist]; !ok {
141-
return []config.MSI{}
176+
return nil
142177
}
143178
return []config.MSI{
144179
WinPackage(dist),
@@ -160,9 +195,9 @@ func WinPackage(dist string) config.MSI {
160195
}
161196
}
162197

163-
func Packages(dist string) (r []config.NFPM) {
198+
func Packages(dist string) []config.NFPM {
164199
if dist == K8sDistro {
165-
return []config.NFPM{}
200+
return nil
166201
}
167202
return []config.NFPM{
168203
Package(dist),
@@ -191,21 +226,17 @@ func Package(dist string) config.NFPM {
191226
})
192227
}
193228
return config.NFPM{
194-
ID: dist,
195-
Builds: []string{dist},
196-
Formats: []string{"deb", "rpm"},
197-
229+
ID: dist,
230+
Builds: []string{dist},
231+
Formats: []string{"deb", "rpm"},
198232
License: "Apache 2.0",
199233
Description: fmt.Sprintf("OpenTelemetry Collector - %s", dist),
200234
Maintainer: "The OpenTelemetry Collector maintainers <[email protected]>",
201235
Overrides: map[string]config.NFPMOverridables{
202236
"rpm": {
203-
Dependencies: []string{
204-
"/bin/sh",
205-
},
237+
Dependencies: []string{"/bin/sh"},
206238
},
207239
},
208-
209240
NFPMOverridables: config.NFPMOverridables{
210241
PackageName: dist,
211242
Scripts: config.NFPMScripts{
@@ -219,16 +250,14 @@ func Package(dist string) config.NFPM {
219250
}
220251

221252
func DockerImages(dist string) []config.Docker {
222-
r := make([]config.Docker, 0)
253+
var r []config.Docker
223254
for _, arch := range Architectures {
224-
if dist == K8sDistro {
225-
if _, ok := K8sDockerSkipArchs[arch]; ok {
226-
continue
227-
}
255+
if dist == K8sDistro && K8sDockerSkipArchs[arch] {
256+
continue
228257
}
229258
switch arch {
230259
case ArmArch:
231-
for _, vers := range ArmVersions {
260+
for _, vers := range ArmVersions(dist) {
232261
r = append(r, DockerImage(dist, arch, vers))
233262
}
234263
default:
@@ -302,7 +331,7 @@ func DockerManifest(prefix, version, dist string) config.DockerManifest {
302331
}
303332
switch arch {
304333
case ArmArch:
305-
for _, armVers := range ArmVersions {
334+
for _, armVers := range ArmVersions(dist) {
306335
dockerArchTag := strings.ReplaceAll(archName(arch, armVers), "/", "")
307336
imageTemplates = append(
308337
imageTemplates,

0 commit comments

Comments
 (0)