Skip to content

E2E - Pepr Excellent Examples #145

E2E - Pepr Excellent Examples

E2E - Pepr Excellent Examples #145

name: E2E - Pepr Excellent Examples
permissions: read-all
on:
workflow_dispatch:
schedule:
- cron: '0 4 * * *' # 12AM EST/9PM PST
# 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@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: clone pepr
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
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@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20
cache: "npm"
cache-dependency-path: pepr
- name: install pepr deps
run: |
cd "$PEPR"
npm ci
- name: build pepr image
run: |
cd "$PEPR"
npm run build:image
- 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 image tar artifact
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: pepr-img.tar
path: pepr-img.tar
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@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: clone pepr
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: defenseunicorns/pepr-excellent-examples
path: pepr-excellent-examples
- name: "set env: PEXEX"
run: echo "PEXEX=${GITHUB_WORKSPACE}/pepr-excellent-examples" >> "$GITHUB_ENV"
- name: setup node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20
cache: "npm"
cache-dependency-path: pepr
- name: create matrix
run: |
matrix=$(
node "$PEPR/.github/workflows/pepr-excellent-examples-matrix.js" "$PEXEX"
)
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: 5
matrix: ${{ fromJSON(needs.examples-matrix.outputs.matrix) }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.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: dowload image tar artifact
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: pepr-img.tar
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: defenseunicorns/pepr-excellent-examples
path: pepr-excellent-examples
- name: "set env: PEXEX"
run: echo "PEXEX=${GITHUB_WORKSPACE}/pepr-excellent-examples" >> "$GITHUB_ENV"
- name: setup node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20
cache: "npm"
cache-dependency-path: pepr-excellent-examples
- name: install pepr-excellent-examples deps
run: |
cd "$PEXEX"
npm ci
- name: run e2e tests
run: |
cd "$PEXEX"
npm run --workspace=${{ matrix.name }} test:e2e -- --image pepr:dev