Skip to content

Commit

Permalink
feat: Refactoring ci to facilitate multiple distros
Browse files Browse the repository at this point in the history
  • Loading branch information
mailo-nr committed Jan 29, 2025
1 parent 55437c7 commit 9548f31
Show file tree
Hide file tree
Showing 45 changed files with 1,842 additions and 1,356 deletions.
3 changes: 3 additions & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# .actrc
--container-architecture=linux/arm64
-P ubuntu-latest=catthehacker/ubuntu:act-latest
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

env:
TEST_CLUSTER_NAME: ci-e2etest-nightly
REGISTRY: ${{ secrets.OTELCOMM_AWS_TEST_ACC_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com/nr-otel-collector
REGISTRY: ${{ secrets.OTELCOMM_AWS_TEST_ACC_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com

jobs:
slow-tests:
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
gpg_private_key: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }}
passphrase: ${{ secrets.OHAI_GPG_PASSPHRASE }}

- name: Write GPG to path in memory
- name: Write GPG to path in memory for signing rpm/deb
id: write_gpg_to_path
run: |
GPG_KEY_PATH="$(mktemp /dev/shm/gpg.XXXXXX)"
Expand Down
75 changes: 0 additions & 75 deletions .github/workflows/ci-prerelease.yml

This file was deleted.

53 changes: 0 additions & 53 deletions .github/workflows/ci-release.yml

This file was deleted.

54 changes: 45 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ jobs:
build:
name: Validate distributions build, third party libraries and security
runs-on: ubuntu-latest
strategy:
matrix:
dist:
# - nr-otel-collector
- nrdot-collector-k8s
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -29,25 +34,55 @@ jobs:
go-version: '1.23'
check-latest: true

- name: Tidy go.mod files
run: go mod tidy

- name: Verify build
run: make ci
run: make ci DISTRIBUTIONS=${{ matrix.dist }}

- name: Validate distributions third party libraries
run: make licenses-check
- name: Login to Docker
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.OTELCOMM_DOCKERHUB_USERNAME }}
password: ${{ secrets.OTELCOMM_DOCKERHUB_PASSWORD }}

- uses: docker/setup-qemu-action@v2

- uses: docker/setup-buildx-action@v2

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }}
passphrase: ${{ secrets.OHAI_GPG_PASSPHRASE }}

- name: Write GPG to path in memory for signing rpm/deb
id: write_gpg_to_path
run: |
GPG_KEY_PATH="$(mktemp /dev/shm/gpg.XXXXXX)"
echo "$GPG_PRIVATE_KEY" | base64 -d >> "$GPG_KEY_PATH"
echo "gpg_key_path=$GPG_KEY_PATH" >> $GITHUB_OUTPUT
env:
GPG_PRIVATE_KEY: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }}

- name: Build binaries & packages with GoReleaser
id: goreleaser
uses: goreleaser/goreleaser-action@v6
env:
NFPM_PASSPHRASE: ${{ secrets.OHAI_GPG_PASSPHRASE }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GPG_KEY_PATH: ${{ steps.write_gpg_to_path.outputs.gpg_key_path }}
REGISTRY: "newrelic/${{ matrix.dist }}"
with:
distribution: goreleaser
version: '~> v2'
args: --snapshot --clean --skip=sign --timeout 2h
args: --snapshot --clean --skip=publish,validate --timeout 2h
workdir: distributions/${{ matrix.dist }}

- name: Extract image version
run: echo "version=$(jq -r '.version' dist/metadata.json)" >> $GITHUB_ENV
run: echo "version=$(echo '${{ steps.goreleaser.outputs.metadata }}' | jq -r '.version')" >> $GITHUB_ENV

- name: Setup local kind cluster
uses: helm/kind-action@v1
Expand All @@ -58,14 +93,14 @@ jobs:

- name: Run local e2e tests
run: |
IMAGE_TAG=${{ env.version }}-rc-amd64 \
IMAGE_TAG=${{ env.version }}-amd64 \
KIND_CLUSTER_NAME=${{ env.TEST_CLUSTER_NAME }} \
make -f ./test/e2e/Makefile ci_test-fast
- name: Trivy security check
uses: aquasecurity/trivy-action@0.28.0
uses: aquasecurity/trivy-action@0.29.0
with:
image-ref: "newrelic/nr-otel-collector:${{ env.version }}-rc-amd64"
image-ref: "newrelic/${{ matrix.dist }}:${{ env.version }}-amd64"
format: 'table'
exit-code: '1'
ignore-unfixed: true
Expand All @@ -75,8 +110,9 @@ jobs:
# dbs are downloaded async in download_trivy_db.yml
TRIVY_SKIP_DB_UPDATE: true
TRIVY_SKIP_JAVA_DB_UPDATE: true

terraform:
uses: ./.github/workflows/component_terraform.yml
uses: ./.github/workflows/terraform.yml
if: github.event.pull_request.user.login != 'dependabot[bot]'
with:
branch: ${{ github.ref }}
Expand Down
123 changes: 0 additions & 123 deletions .github/workflows/component_publish.yml

This file was deleted.

Loading

0 comments on commit 9548f31

Please sign in to comment.