Skip to content

Commit

Permalink
run package tests nightly against latest main
Browse files Browse the repository at this point in the history
Signed-off-by: Moritz Wiesinger <[email protected]>
  • Loading branch information
mowies committed Nov 14, 2024
1 parent 26c3dee commit 860fc05
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 11 deletions.
55 changes: 54 additions & 1 deletion .github/workflows/base-ci-goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
goarch:
required: true
type: string
latest:
required: false
type: boolean
default: false

jobs:
check-goreleaser:
Expand Down Expand Up @@ -60,9 +64,58 @@ jobs:
go-version: '1.23'
check-latest: true

- name: Generate the sources
- name: Get latest finished run ID from contrib repo build-and-test
id: get-run-id
if: inputs.latest == true
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 "run_id=$run_id" >> "$GITHUB_OUTPUT"
- run: mkdir -p distributions/otelcol-contrib/artifacts/otelcol-contrib_linux_amd64_v1
if: ${{ inputs.distribution == 'otelcol-contrib' && inputs.latest == true }}

- name: Download built otelcontribcol artifact from contrib repo
if: inputs.latest == true
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: Rename downloaded artifact
if: inputs.latest == true
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.latest != true
env:
DISTRIBUTIONS: ${{ inputs.distribution }}
run: make generate-sources

- name: Run split GoReleaser build for otelcol-contrib
if: ${{ inputs.distribution == 'otelcol-contrib' && inputs.latest != true }}
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
with:
distribution: goreleaser-pro
version: v2.3.2
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 }}

- if: ${{ inputs.distribution == 'otelcol-contrib' && inputs.latest != true }}
run: mv distributions/otelcol-contrib/dist/**/* distributions/otelcol-contrib/artifacts/

- run: ls -laR distributions/otelcol-contrib/artifacts
if: ${{ inputs.distribution == 'otelcol-contrib' }}

- name: Run GoReleaser for ${{ inputs.distribution }}
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
with:
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/nightly-package-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Nightly Package Tests - Contrib - GoReleaser

on:
push:
branches: [main]
paths:
- "distributions/otelcol-contrib/**"
- "cmd/**"
- ".github/**"
- "scripts/**"
- "Makefile"
- "go.mod"
- "go.sum"
pull_request:
branches: [main]
paths:
- "distributions/otelcol-contrib/**"
- "cmd/**"
- ".github/**"
- "scripts/**"
- "Makefile"
- "go.mod"
- "go.sum"
# schedule:
# -

jobs:
check-goreleaser:
name: Continuous Integration - Contrib - GoReleaser
uses: ./.github/workflows/base-ci-goreleaser.yaml
with:
distribution: otelcol-contrib
goos: '[ "linux" ]'
goarch: '[ "amd64" ]'
latest: true
secrets: inherit

package-tests:
name: Package tests
needs: check-goreleaser
uses: ./.github/workflows/package-tests.yaml
with:
distribution: otelcol-contrib
type: '[ "deb", "rpm" ]'
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ OTELCOL_BUILDER_VERSION ?= 0.113.0
OTELCOL_BUILDER_DIR ?= ${HOME}/bin
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb

DISTRIBUTIONS ?= "otelcol,otelcol-contrib,otelcol-k8s,otelcol-otlp"
DISTRIBUTIONS ?= "otelcol-contrib"

ci: check build
check: ensure-goreleaser-up-to-date
Expand Down Expand Up @@ -92,4 +92,4 @@ delete-tags:
# Used for debug only
REMOTE?[email protected]:open-telemetry/opentelemetry-collector-releases.git
.PHONY: repeat-tags
repeat-tags: delete-tags push-tags
repeat-tags: delete-tags push-tags
43 changes: 43 additions & 0 deletions distributions/otelcol-contrib/.goreleaser-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
partial:
by: target
version: 2
project_name: opentelemetry-collector-releases
builds:
- id: otelcol-contrib
goos:
- darwin
- linux
- windows
goarch:
- "386"
- amd64
- arm
- arm64
- ppc64le
- s390x
goarm:
- "7"
ignore:
- goos: darwin
goarch: "386"
- goos: darwin
goarch: arm
- goos: darwin
goarch: s390x
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
- goos: windows
goarch: s390x
dir: _build
binary: otelcol-contrib
ldflags:
- -s
- -w
flags:
- -trimpath
env:
- CGO_ENABLED=0
monorepo:
tag_prefix: v
10 changes: 3 additions & 7 deletions distributions/otelcol-contrib/.goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ msi:
- config.yaml
builds:
- id: otelcol-contrib
builder: prebuilt
prebuilt:
path: artifacts/otelcol-contrib_{{ .Os }}_{{ .Arch }}{{ with .Arm }}_{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}/otelcol-contrib{{- if eq .Os "windows" }}.exe{{ end }}
goos:
- darwin
- linux
Expand Down Expand Up @@ -41,13 +44,6 @@ builds:
goarch: s390x
dir: _build
binary: otelcol-contrib
ldflags:
- -s
- -w
flags:
- -trimpath
env:
- CGO_ENABLED=0
archives:
- id: otelcol-contrib
builds:
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ BUILDER=''
# default values
skipcompilation=false

while getopts d:s:b:g: flag
while getopts d:s:b: flag
do
case "${flag}" in
d) distributions=${OPTARG};;
Expand Down

0 comments on commit 860fc05

Please sign in to comment.