Skip to content

Commit

Permalink
Revert "test: run linux package tests nightly against latest contrib …
Browse files Browse the repository at this point in the history
…main (#666)" (#761)

This reverts commit 1271690.
  • Loading branch information
TylerHelmuth authored Dec 4, 2024
1 parent 3ae3def commit a61f843
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 233 deletions.
73 changes: 1 addition & 72 deletions .github/workflows/base-ci-goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ on:
goarch:
required: true
type: string
nightly:
required: false
type: boolean
default: false
description: "Set to true to fetch latest otelcol-contrib main branch version instead of building the version in this repo"

env:
# renovate: datasource=github-tags depName=goreleaser-pro packageName=goreleaser/goreleaser-pro
Expand Down Expand Up @@ -69,75 +64,9 @@ jobs:
go-version: '1.23'
check-latest: true

- name: Create artifacts directory to store build artifacts
if: inputs.distribution == 'otelcol-contrib'
run: mkdir -p distributions/otelcol-contrib/artifacts

- name: "[Nightly] Get latest finished run ID from contrib repo build-and-test"
id: get-run-id
if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(gh run list \
--branch main \
--workflow build-and-test \
--repo open-telemetry/opentelemetry-collector-contrib \
--limit 1 \
--status success \
--json databaseId \
--jq '.[0].databaseId' \
)
echo "Found run ID: $run_id"
echo "run_id=$run_id" >> "$GITHUB_OUTPUT"
- name: "[Nightly] Create sub-directory for otelcol-contrib nightly build"
if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux'
run: mkdir -p distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1

- name: "[Nightly] Download built otelcol-contrib artifact from contrib repo"
if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux'
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: collector-binaries-linux-amd64
repository: open-telemetry/opentelemetry-collector-contrib
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ steps.get-run-id.outputs.run_id }}

- name: "[Nightly] Move downloaded artifact"
if: inputs.distribution == 'otelcol-contrib' && inputs.nightly == true && matrix.GOARCH == 'amd64' && matrix.GOOS == 'linux'
run: mv otelcontribcol_linux_amd64 distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1/otelcol-contrib

- name: Generate the sources for ${{ inputs.distribution }}
if: inputs.nightly != true
env:
DISTRIBUTIONS: ${{ inputs.distribution }}
- name: Generate the sources
run: make generate-sources

# otelcol-contrib is built in a separate stage
- name: Build ${{ inputs.distribution }}
if: inputs.distribution == 'otelcol-contrib' && inputs.nightly != true
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
with:
distribution: goreleaser-pro
version: ${{ env.GORELEASER_PRO_VERSION }}
workdir: distributions/otelcol-contrib
args: --snapshot --clean --timeout 2h --split --config .goreleaser-build.yaml
env:
GOOS: ${{ matrix.GOOS }}
GOARCH: ${{ matrix.GOARCH }}
GOARM: 7 # Default is 6
GOAMD64: v1
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

- name: Move built artifacts
if: inputs.distribution == 'otelcol-contrib' && inputs.nightly != true
run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/

- name: Show built or downloaded content
if: inputs.distribution == 'otelcol-contrib'
run: ls -laR distributions/otelcol-contrib/artifacts

- name: Run GoReleaser for ${{ inputs.distribution }}
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-goreleaser-contrib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
package-tests:
name: Package tests
needs: check-goreleaser
uses: ./.github/workflows/base-package-tests.yaml
uses: ./.github/workflows/package-tests.yaml
with:
distribution: otelcol-contrib
type: '[ "deb", "rpm" ]'
2 changes: 1 addition & 1 deletion .github/workflows/ci-goreleaser-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
package-tests:
name: Package tests
needs: check-goreleaser
uses: ./.github/workflows/base-package-tests.yaml
uses: ./.github/workflows/package-tests.yaml
with:
distribution: otelcol
type: '[ "deb", "rpm" ]'
24 changes: 0 additions & 24 deletions .github/workflows/package-test.yaml

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ delete-tags:
# Used for debug only
REMOTE?=git@github.com:open-telemetry/opentelemetry-collector-releases.git
.PHONY: repeat-tags
repeat-tags: delete-tags push-tags
repeat-tags: delete-tags push-tags
119 changes: 45 additions & 74 deletions cmd/goreleaser/internal/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,22 @@ const (
var (
ImagePrefixes = []string{DockerHub, GHCR}
Architectures = []string{"386", "amd64", "arm", "arm64", "ppc64le", "s390x"}
ArmVersions = []string{"7"}
DefaultConfigDists = map[string]bool{CoreDistro: true, ContribDistro: true}
MSIWindowsDists = map[string]bool{CoreDistro: true, ContribDistro: true, OTLPDistro: true}
K8sDockerSkipArchs = map[string]bool{"arm": true, "386": true}
K8sGoos = []string{"linux"}
K8sArchs = []string{"amd64", "arm64", "ppc64le", "s390x"}
)

func GenerateContribBuildOnly(dist string, buildOrRest bool) config.Project {
return config.Project{
ProjectName: "opentelemetry-collector-releases",
Builds: Builds(dist, buildOrRest),
Version: 2,
Monorepo: config.Monorepo{
TagPrefix: "v",
},
}
}

func Generate(dist string, buildOrRest bool) config.Project {
func Generate(dist string) config.Project {
return config.Project{
ProjectName: "opentelemetry-collector-releases",
Checksum: config.Checksum{
NameTemplate: fmt.Sprintf("{{ .ProjectName }}_%v_checksums.txt", dist),
},
Env: []string{"COSIGN_YES=true"},
Builds: Builds(dist, buildOrRest),
Builds: Builds(dist),
Archives: Archives(dist),
MSI: WinPackages(dist),
NFPMs: Packages(dist),
Expand All @@ -83,41 +73,37 @@ func Generate(dist string, buildOrRest bool) config.Project {
}
}

func Builds(dist string, buildOrRest bool) []config.Build {
func Builds(dist string) []config.Build {
return []config.Build{
Build(dist, buildOrRest),
Build(dist),
}
}

// Build configures a goreleaser build.
// https://goreleaser.com/customization/build/
func Build(dist string, buildOrRest bool) config.Build {
goos := []string{"darwin", "linux", "windows"}
archs := Architectures

if dist == ContribDistro && !buildOrRest {
// only return build config for contrib build file
return config.Build{
ID: dist,
Builder: "prebuilt",
PreBuilt: config.PreBuiltOptions{
Path: "artifacts/otelcol-contrib_{{ .Target }}" +
"/otelcol-contrib{{- if eq .Os \"windows\" }}.exe{{ end }}",
},
Goos: goos,
Goarch: archs,
Goarm: ArmVersions(dist),
Dir: "_build",
Binary: dist,
Ignore: IgnoreBuildCombinations(dist),
}
}

func Build(dist string) config.Build {
var goos []string
var archs []string
var ignore []config.IgnoredBuild
var armVersions []string
if dist == K8sDistro {
goos = K8sGoos
archs = K8sArchs
ignore = make([]config.IgnoredBuild, 0)
armVersions = make([]string, 0)
} else {
goos = []string{"darwin", "linux", "windows"}
archs = Architectures
ignore = []config.IgnoredBuild{
{Goos: "darwin", Goarch: "386"},
{Goos: "darwin", Goarch: "arm"},
{Goos: "darwin", Goarch: "s390x"},
{Goos: "windows", Goarch: "arm"},
{Goos: "windows", Goarch: "arm64"},
{Goos: "windows", Goarch: "s390x"},
}
armVersions = ArmVersions
}

return config.Build{
ID: dist,
Dir: "_build",
Expand All @@ -129,33 +115,12 @@ func Build(dist string, buildOrRest bool) config.Build {
},
Goos: goos,
Goarch: archs,
Goarm: ArmVersions(dist),
Ignore: IgnoreBuildCombinations(dist),
Goarm: armVersions,
Ignore: ignore,
}
}

func IgnoreBuildCombinations(dist string) []config.IgnoredBuild {
if dist == K8sDistro {
return nil
}
return []config.IgnoredBuild{
{Goos: "darwin", Goarch: "386"},
{Goos: "darwin", Goarch: "arm"},
{Goos: "darwin", Goarch: "s390x"},
{Goos: "windows", Goarch: "arm"},
{Goos: "windows", Goarch: "arm64"},
{Goos: "windows", Goarch: "s390x"},
}
}

func ArmVersions(dist string) []string {
if dist == K8sDistro {
return nil
}
return []string{"7"}
}

func Archives(dist string) []config.Archive {
func Archives(dist string) (r []config.Archive) {
return []config.Archive{
Archive(dist),
}
Expand All @@ -173,7 +138,7 @@ func Archive(dist string) config.Archive {

func WinPackages(dist string) []config.MSI {
if _, ok := MSIWindowsDists[dist]; !ok {
return nil
return []config.MSI{}
}
return []config.MSI{
WinPackage(dist),
Expand All @@ -195,9 +160,9 @@ func WinPackage(dist string) config.MSI {
}
}

func Packages(dist string) []config.NFPM {
func Packages(dist string) (r []config.NFPM) {
if dist == K8sDistro {
return nil
return []config.NFPM{}
}
return []config.NFPM{
Package(dist),
Expand Down Expand Up @@ -226,17 +191,21 @@ func Package(dist string) config.NFPM {
})
}
return config.NFPM{
ID: dist,
Builds: []string{dist},
Formats: []string{"deb", "rpm"},
ID: dist,
Builds: []string{dist},
Formats: []string{"deb", "rpm"},

License: "Apache 2.0",
Description: fmt.Sprintf("OpenTelemetry Collector - %s", dist),
Maintainer: "The OpenTelemetry Collector maintainers <cncf-opentelemetry-maintainers@lists.cncf.io>",
Overrides: map[string]config.NFPMOverridables{
"rpm": {
Dependencies: []string{"/bin/sh"},
Dependencies: []string{
"/bin/sh",
},
},
},

NFPMOverridables: config.NFPMOverridables{
PackageName: dist,
Scripts: config.NFPMScripts{
Expand All @@ -250,14 +219,16 @@ func Package(dist string) config.NFPM {
}

func DockerImages(dist string) []config.Docker {
var r []config.Docker
r := make([]config.Docker, 0)
for _, arch := range Architectures {
if dist == K8sDistro && K8sDockerSkipArchs[arch] {
continue
if dist == K8sDistro {
if _, ok := K8sDockerSkipArchs[arch]; ok {
continue
}
}
switch arch {
case ArmArch:
for _, vers := range ArmVersions(dist) {
for _, vers := range ArmVersions {
r = append(r, DockerImage(dist, arch, vers))
}
default:
Expand Down Expand Up @@ -331,7 +302,7 @@ func DockerManifest(prefix, version, dist string) config.DockerManifest {
}
switch arch {
case ArmArch:
for _, armVers := range ArmVersions(dist) {
for _, armVers := range ArmVersions {
dockerArchTag := strings.ReplaceAll(archName(arch, armVers), "/", "")
imageTemplates = append(
imageTemplates,
Expand Down
10 changes: 1 addition & 9 deletions cmd/goreleaser/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,21 @@ import (
"log"
"os"

"github.com/goreleaser/goreleaser-pro/v2/pkg/config"
"gopkg.in/yaml.v3"

"github.com/open-telemetry/opentelemetry-collector-releases/cmd/goreleaser/internal"
)

var distFlag = flag.String("d", "", "Collector distributions to build")
var contribBuildOrRestFlag = flag.Bool("generate-build-step", false, "Collector Contrib distribution only - switch between build and package config file - set to true to generate build step, false to generate package step")

func main() {
flag.Parse()

if len(*distFlag) == 0 {
log.Fatal("no distribution to build")
}
var project config.Project

if *distFlag == internal.ContribDistro && *contribBuildOrRestFlag {
// Special care needs to be taken for otelcol-contrib since it has a split setup
project = internal.GenerateContribBuildOnly(*distFlag, *contribBuildOrRestFlag)
} else {
project = internal.Generate(*distFlag, *contribBuildOrRestFlag)
}
project := internal.Generate(*distFlag)

partial := map[string]any{
"partial": map[string]any{
Expand Down
Loading

0 comments on commit a61f843

Please sign in to comment.