-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use shared workflow for ci and nightly (#208)
* feat: Use shared workflow for ci and nightly * chore: Expose image repo * chore: Add publish step * chore: PR feedback and cleanup
- Loading branch information
Showing
17 changed files
with
264 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
name: 🧩 CI Base | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
distribution: | ||
required: true | ||
type: string | ||
nightly: | ||
required: false | ||
type: boolean | ||
default: false | ||
test_cluster_name: | ||
required: false | ||
type: string | ||
default: 'ci-e2etest' | ||
secrets: | ||
registry: | ||
required: false | ||
docker_hub_username: | ||
required: true | ||
docker_hub_password: | ||
required: true | ||
gpg_private_key: | ||
required: true | ||
gpg_passphrase: | ||
required: true | ||
nr_backend_url: | ||
required: false | ||
nr_ingest_key: | ||
required: false | ||
nr_account_id: | ||
required: false | ||
nr_api_base_url: | ||
required: false | ||
nr_api_key: | ||
required: false | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # required for tag metadata | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.23' | ||
check-latest: true | ||
|
||
- name: Tidy go.mod files | ||
run: go mod tidy | ||
|
||
- name: Verify build | ||
run: make ci DISTRIBUTIONS=${{ inputs.distribution }} | ||
|
||
- name: Login to Docker | ||
uses: docker/login-action@v3 | ||
if: ${{ env.ACT }} | ||
with: | ||
registry: docker.io | ||
username: ${{ secrets.docker_hub_username }} | ||
password: ${{ secrets.docker_hub_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.gpg_private_key }} | ||
passphrase: ${{ secrets.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.gpg_private_key }} | ||
|
||
- name: Build Args | ||
run: | | ||
if [ ${{ inputs.nightly }} = "true" ]; then | ||
echo "goreleaser_args=--snapshot --clean --skip=publish,validate --timeout 2h --config .goreleaser-nightly.yaml" >> $GITHUB_ENV | ||
else | ||
echo "goreleaser_args=--snapshot --clean --skip=publish,validate --timeout 2h" >> $GITHUB_ENV | ||
fi | ||
- name: Build binaries & packages with GoReleaser | ||
id: goreleaser | ||
uses: goreleaser/goreleaser-action@v6 | ||
env: | ||
NFPM_PASSPHRASE: ${{ secrets.gpg_passphrase }} | ||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} | ||
GPG_KEY_PATH: ${{ steps.write_gpg_to_path.outputs.gpg_key_path }} | ||
REGISTRY: "${{ secrets.registry }}" | ||
with: | ||
distribution: goreleaser | ||
version: '~> v2' | ||
args: ${{ env.goreleaser_args }} | ||
workdir: distributions/${{ inputs.distribution }} | ||
|
||
- name: Extract image version and arch | ||
run: | | ||
VERSION=$(echo '${{ steps.goreleaser.outputs.metadata }}' | jq -r '.version') | ||
ARCH=$(echo '${{ runner.arch }}' | sed 's/X/amd/g') | ||
ARCH=${ARCH@L} | ||
echo "version=$VERSION" >> $GITHUB_ENV | ||
echo "arch=$ARCH" >> $GITHUB_ENV | ||
if [ ${{ inputs.nightly }} = "true" ]; then | ||
echo "image_tag=$VERSION-nightly-$ARCH" >> $GITHUB_ENV | ||
else | ||
echo "image_tag=$VERSION-$ARCH" >> $GITHUB_ENV | ||
fi | ||
- name: Setup local kind cluster | ||
uses: helm/kind-action@v1 | ||
with: | ||
version: v0.21.0 | ||
cluster_name: ${{ inputs.test_cluster_name }} | ||
wait: 60s | ||
|
||
- uses: azure/[email protected] | ||
|
||
- name: Run local e2e tests | ||
if: ${{ !inputs.nightly }} | ||
env: | ||
KIND_CLUSTER_NAME: ${{ inputs.test_cluster_name }} | ||
IMAGE_TAG: ${{ env.image_tag }} | ||
IMAGE_REPO: ${{ secrets.registry }}/${{ inputs.distribution}} | ||
DISTRO: ${{ inputs.distribution }} | ||
run: | | ||
make -f ./test/e2e/Makefile ci_test-fast | ||
- name: Run slow local tests | ||
if: ${{ inputs.nightly }} | ||
env: | ||
KIND_CLUSTER_NAME: ${{ inputs.test_cluster_name }} | ||
IMAGE_TAG: ${{ env.image_tag }} | ||
IMAGE_REPO: ${{ secrets.registry }}/${{ inputs.distribution}} | ||
DISTRO: ${{ inputs.distribution }} | ||
NR_BACKEND_URL: ${{ secrets.nr_backend_url }} | ||
NR_INGEST_KEY: ${{ secrets.nr_ingest_key }} | ||
NR_API_KEY: ${{ secrets.nr_api_key }} | ||
NR_ACCOUNT_ID: ${{ secrets.nr_account_id }} | ||
NR_API_BASE_URL: ${{ secrets.nr_api_base_url }} | ||
run: | | ||
make -f ./test/e2e/Makefile ci_test-slow | ||
- name: Trivy security check | ||
if: ${{ !inputs.nightly }} | ||
uses: aquasecurity/[email protected] | ||
with: | ||
image-ref: "${{ secrets.registry }}/${{ inputs.distribution}}:${{ env.image_tag }}" | ||
format: 'table' | ||
exit-code: '1' | ||
ignore-unfixed: true | ||
vuln-type: 'os,library' | ||
severity: "HIGH,CRITICAL" | ||
env: | ||
# dbs are downloaded async in trivy-cache.yml | ||
TRIVY_SKIP_DB_UPDATE: ${{ !env.ACT }} | ||
TRIVY_SKIP_JAVA_DB_UPDATE: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.