Skip to content

chore: refactor complex validation processing logic #1058

chore: refactor complex validation processing logic

chore: refactor complex validation processing logic #1058

name: E2E - Pepr Excellent Examples
permissions: read-all
on:
workflow_dispatch:
inputs:
kfcBranch:
description: 'KFC dev branch'
required: false
type: string
default: 'none'
schedule:
- cron: '0 4 * * *' # 12AM EST/9PM PST
push:
branches: ["main"]
pull_request:
branches: ["main"]
# 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@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: clone pepr
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.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@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
cache: "npm"
cache-dependency-path: pepr
- name: install pepr deps
run: |
cd "$PEPR"
npm ci
- name: build pepr package and container image
if: ${{ (github.event.inputs.kfcBranch || 'none') == 'none' }}
run: |
cd "$PEPR"
npm run build:image
mv pepr-0.0.0-development.tgz ${GITHUB_WORKSPACE}/pepr-0.0.0-development.tgz
ls -l ${GITHUB_WORKSPACE}
- name: build pepr package and kfc dev container image
if: ${{ (github.event.inputs.kfcBranch || 'none') != 'none' }}
run: |
cd "$PEPR"
node hack/kfc-dev.js build -b "${{ github.event.inputs.kfcBranch }}"
rm -rf "$PEPR/node_modules/kubernetes-fluent-client/src"
rm -rf "$PEPR/node_modules/kubernetes-fluent-client/dist"
cp -R "$PEPR/kubernetes-fluent-client/src" "$PEPR/node_modules/kubernetes-fluent-client/src"
cp -R "$PEPR/kubernetes-fluent-client/dist" "$PEPR/node_modules/kubernetes-fluent-client/dist"
npm run build
mv pepr-0.0.0-development.tgz ${GITHUB_WORKSPACE}/pepr-0.0.0-development.tgz
ls -l ${GITHUB_WORKSPACE}
- 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:dev
- name: upload artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
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@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: clone pepr
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.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@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
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:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
needs:
- examples-matrix
if: needs.examples-matrix.outputs.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@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: "install k3d"
run: "curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash"
shell: bash
- name: download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.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@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
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@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
with:
max_attempts: 3
retry_on: error
timeout_minutes: 6
command: |
cd "$PEPR_EXCELLENT_EXAMPLES_PATH"
npm run --workspace=${{ matrix.name }} test:e2e -- \
--image pepr:dev \
--custom-package ../pepr-0.0.0-development.tgz
- name: upload artifacts (troubleshooting)
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
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