Skip to content

E2E - Pepr Excellent Examples - Unicorn #4153

E2E - Pepr Excellent Examples - Unicorn

E2E - Pepr Excellent Examples - Unicorn #4153

name: E2E - Pepr Excellent Examples - Unicorn
permissions:
id-token: write # This is needed for OIDC federation.
contents: read
on:
workflow_dispatch:
schedule:
- cron: '0 4 * * *' # 12AM EST/9PM PST
pull_request:
branches: ["main"]
paths-ignore:
- "**.md"
- "LICENSE"
- "CODEOWNERS"
# refs
# https://frontside.com/blog/2022-12-12-dynamic-github-action-jobs/
# https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
jobs:
pepr-build:
name: controller image
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
with:
egress-policy: audit
- name: clone pepr
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: defenseunicorns/pepr
path: pepr
- name: "set env: PEPR"
run: echo "PEPR=${GITHUB_WORKSPACE}/pepr" >> "$GITHUB_ENV"
- name: setup node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
cache: "npm"
cache-dependency-path: pepr
- name: install pepr deps
run: |
cd "$PEPR"
npm ci
- name: Login to Chainguard
uses: chainguard-dev/setup-chainctl@2cddd35a2f120d9973e58094dc6878c93cf58c28 # v0.5.1
with:
identity: ${{ secrets.CHAINGUARD_IDENTITY }}
- name: build pepr package and container image
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
max_attempts: 3
retry_on: error
timeout_minutes: 10
command: |
cd "$PEPR"
npm run build:image:unicorn
mv pepr-0.0.0-development.tgz ${GITHUB_WORKSPACE}/pepr-0.0.0-development.tgz
- name: tar pepr image
run: |
PEPR_TAR="${GITHUB_WORKSPACE}/pepr-img.tar"
echo "PEPR_TAR=${PEPR_TAR}" >> "$GITHUB_ENV"
docker image save --output "$PEPR_TAR" pepr/private:dev
- name: upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pepr-package-and-controller-image
path: |
pepr-0.0.0-development.tgz
pepr-img.tar
if-no-files-found: error
retention-days: 1
examples-matrix:
name: job matrix
runs-on: ubuntu-latest
needs:
- pepr-build
outputs:
matrix: ${{ steps.create-matrix.outputs.matrix }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
with:
egress-policy: audit
- name: clone pepr
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: defenseunicorns/pepr
path: pepr
- name: "set env: PEPR"
run: echo "PEPR=${GITHUB_WORKSPACE}/pepr" >> "$GITHUB_ENV"
- name: clone pepr-excellent-examples
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: defenseunicorns/pepr-excellent-examples
path: pepr-excellent-examples
- name: "set env: PEPR_EXCELLENT_EXAMPLES_PATH"
run: echo "PEPR_EXCELLENT_EXAMPLES_PATH=${GITHUB_WORKSPACE}/pepr-excellent-examples" >> "$GITHUB_ENV"
- name: setup node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
cache: "npm"
cache-dependency-path: pepr
- name: create matrix
run: |
matrix=$(
node "$PEPR/.github/workflows/pepr-excellent-examples-matrix.js" "$PEPR_EXCELLENT_EXAMPLES_PATH"
)
echo "matrix=${matrix}" >> "$GITHUB_OUTPUT"
id: create-matrix
excellent-examples:
if: needs.examples-matrix.outputs.matrix != ''
name: ${{ matrix.name }}
runs-on: ubuntu-latest
needs:
- examples-matrix
strategy:
fail-fast: false
max-parallel: 32 # Roughly matches the number of E2E tests and below GitHub concurrency limit
matrix: ${{ fromJSON(needs.examples-matrix.outputs.matrix) }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@ab7a9404c0f3da075243ca237b5fac12c98deaa5 # v2.19.3
with:
egress-policy: audit
- name: "install k3d"
run: "curl -s --retry 5 --retry-all-errors --fail https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash"
shell: bash
- name: download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: pepr-package-and-controller-image
path: ${{ github.workspace }}
- name: import pepr image from tar
run: |
PEPR_TAR="${GITHUB_WORKSPACE}/pepr-img.tar"
echo "PEPR_TAR=${PEPR_TAR}" >> "$GITHUB_ENV"
docker image load --input "$PEPR_TAR"
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: defenseunicorns/pepr-excellent-examples
path: pepr-excellent-examples
- name: "set env: PEPR_EXCELLENT_EXAMPLES_PATH"
run: echo "PEPR_EXCELLENT_EXAMPLES_PATH=${GITHUB_WORKSPACE}/pepr-excellent-examples" >> "$GITHUB_ENV"
- name: setup node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
cache: "npm"
cache-dependency-path: pepr-excellent-examples
- name: install pepr-excellent-examples deps
run: |
cd "$PEPR_EXCELLENT_EXAMPLES_PATH"
npm ci
- name: run e2e tests
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
max_attempts: 3
retry_on: error
timeout_minutes: 8
command: |
cd "$PEPR_EXCELLENT_EXAMPLES_PATH"
npm run --workspace=${{ matrix.name }} test:e2e -- \
--image pepr/private:dev \
--custom-package ../pepr-0.0.0-development.tgz
- name: upload artifacts (troubleshooting)
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: "troubleshooting_logs_${{matrix.name}}"
path: |
pepr-excellent-examples/package.json
pepr-excellent-examples/package-lock.json
if-no-files-found: error
retention-days: 1