Skip to content

E2E - Pepr Excellent Examples #58

E2E - Pepr Excellent Examples

E2E - Pepr Excellent Examples #58

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: clone pepr
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
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@v4
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: clone pepr
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
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@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
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: "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@v4
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@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
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