From 860fc0538230fb5cd0c890da011f80072146d86b Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Thu, 19 Sep 2024 09:10:15 +0200 Subject: [PATCH] run package tests nightly against latest main Signed-off-by: Moritz Wiesinger --- .github/workflows/base-ci-goreleaser.yaml | 55 ++++++++++++++++++- .github/workflows/nightly-package-tests.yml | 44 +++++++++++++++ Makefile | 4 +- .../otelcol-contrib/.goreleaser-build.yaml | 43 +++++++++++++++ .../otelcol-contrib/.goreleaser.yaml | 10 +--- scripts/build.sh | 2 +- 6 files changed, 147 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/nightly-package-tests.yml create mode 100644 distributions/otelcol-contrib/.goreleaser-build.yaml diff --git a/.github/workflows/base-ci-goreleaser.yaml b/.github/workflows/base-ci-goreleaser.yaml index 12772029..b62d2554 100644 --- a/.github/workflows/base-ci-goreleaser.yaml +++ b/.github/workflows/base-ci-goreleaser.yaml @@ -12,6 +12,10 @@ on: goarch: required: true type: string + latest: + required: false + type: boolean + default: false jobs: check-goreleaser: @@ -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: diff --git a/.github/workflows/nightly-package-tests.yml b/.github/workflows/nightly-package-tests.yml new file mode 100644 index 00000000..511204fe --- /dev/null +++ b/.github/workflows/nightly-package-tests.yml @@ -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" ]' diff --git a/Makefile b/Makefile index 3c766a5d..9255ff32 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 \ No newline at end of file +repeat-tags: delete-tags push-tags diff --git a/distributions/otelcol-contrib/.goreleaser-build.yaml b/distributions/otelcol-contrib/.goreleaser-build.yaml new file mode 100644 index 00000000..b5f60c0d --- /dev/null +++ b/distributions/otelcol-contrib/.goreleaser-build.yaml @@ -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 diff --git a/distributions/otelcol-contrib/.goreleaser.yaml b/distributions/otelcol-contrib/.goreleaser.yaml index 593efbbc..fb450769 100644 --- a/distributions/otelcol-contrib/.goreleaser.yaml +++ b/distributions/otelcol-contrib/.goreleaser.yaml @@ -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 @@ -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: diff --git a/scripts/build.sh b/scripts/build.sh index bcf810b3..e6b325f4 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -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};;