Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: run linux package tests nightly against latest contrib main [new] #762

Merged
merged 11 commits into from
Dec 19, 2024
73 changes: 72 additions & 1 deletion .github/workflows/base-ci-goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ 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 @@ -64,9 +69,75 @@ jobs:
go-version: '1.23'
check-latest: true

- name: Generate the sources
- 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 }}
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
jobs:
package-tests:
name: Package Tests
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
type: ${{ fromJSON(inputs.type) }}
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/base-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,36 @@ jobs:
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

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

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

- name: Move built artifacts
if: inputs.distribution == 'otelcol-contrib'
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

- uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
with:
distribution: goreleaser-pro
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/package-tests.yaml
uses: ./.github/workflows/base-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/package-tests.yaml
uses: ./.github/workflows/base-package-tests.yaml
with:
distribution: otelcol
type: '[ "deb", "rpm" ]'
24 changes: 24 additions & 0 deletions .github/workflows/package-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Package Tests - Contrib

on:
schedule:
- cron: "0 2 * * *" # every day at 2am UTC

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

package-tests:
name: Linux Package tests
needs: check-goreleaser
uses: ./.github/workflows/base-package-tests.yaml
with:
distribution: otelcol-contrib
type: '[ "deb", "rpm" ]'
Loading
Loading