Skip to content

Main CI workflow

Main CI workflow #459

Workflow file for this run

name: Main CI workflow
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * MON,THU" # every MON,THU at midnight run E2E tests
push:
branches:
- main
- "*"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CYPRESS_CACHE_FOLDER: ${{ github.workspace }}/.cache/Cypress
CYPRESS_EMAIL_POST: ${{ secrets.CYPRESS_EMAIL_POST }}
CYPRESS_EMAIL_PRE: ${{ secrets.CYPRESS_EMAIL_PRE }}
CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }}
CYPRESS_MAILSLURP_API_KEY: ${{ secrets.CYPRESS_MAILSLURP_API_KEY }}
STATIC_IP_HTTP_PROXY: ${{ secrets.STATIC_IP_HTTP_PROXY }}
CACHE_VER: v01
PNPM_VER: 6.32.6
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
build:
name: Install ⚙️ & Examples Matrix 🔧
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Install pnpm 🔧
uses: pnpm/action-setup@v2.2.4
with:
version: ${{env.PNPM_VER}}
## from https://github.com/vercel/next.js/blob/canary/.github/workflows/build_test_deploy.yml#L28
- name: Cache all Repo for next jobs 💾
uses: actions/cache@v3
id: cache-build
with:
path: ./*
key: ${{ github.sha }}
- name: Cache .pnpm-store 💾
if: steps.cache-build.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{env.CACHE_VER}}-${{ hashFiles('**/pnpm-lock.yaml')}}
restore-keys: |
${{ runner.os }}-pnpm-${{env.CACHE_VER}}-
- name: Cache Cypress 💾
if: steps.cache-build.outputs.cache-hit != 'true'
id: cypress-cache
uses: actions/cache@v3
with:
path: ${{env.CYPRESS_CACHE_FOLDER}}
key: ${{ runner.os }}-cypress-${{ github.ref }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-cypress-${{ github.ref }}-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Install dependencies 🔧
if: steps.cache-build.outputs.cache-hit != 'true'
run: |
pnpm install
- name: Check Cypress Cache list
run: cd examples/sitemap && pnpm cypress cache list
- name: Create Matrix Examples ⚡
id: matrix
run: pnpm ts-node ./scripts/listExamples.ts
examplesTest:
name: Test Example
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [build]
strategy:
fail-fast: false
matrix:
example: ${{fromJson(needs.build.outputs.matrix)}}
steps:
- name: Install pnpm 🔧
uses: pnpm/action-setup@v2.2.4
with:
version: ${{env.PNPM_VER}}
- name: Restore Cache 💾
uses: actions/cache@v3
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- name: Test 🏗️
id: cypress-test
run: |
cd examples/${{ matrix.example }}
pnpm postsetup || echo "no postsetup"
pnpm test
- name: Upload Video 📹
uses: actions/upload-artifact@v3
if: failure()
with:
name: video from example ${{ matrix.example }}
path: ${{ github.workspace }}/examples/${{ matrix.example }}/cypress/videos
retention-days: 10
- name: Store Report XML Results
uses: actions/upload-artifact@v3
if: success()
with:
name: report-xml-${{ matrix.example }}
path: report/*.xml
retention-days: 1
examplesResults:
name: Result Examples 📊
runs-on: ubuntu-latest
timeout-minutes: 2
if: always()
needs: [build, examplesTest]
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Install pnpm 🔧
uses: pnpm/action-setup@v2.2.4
with:
version: ${{env.PNPM_VER}}
- name: Install only packages needed for core
run: pnpm add -W ts-node
- name: Downlod report Artifacts
uses: actions/download-artifact@v3
with:
path: report
- name: Move all reports to root report folder
run: |
mv ./report/*/*.xml ./report/ # dont use '-force' to check for errors
- name: Merge all Reports
run: |
pnpm merge
- name: Publish Cypress E2E Report 📖
uses: dorny/test-reporter@v1
with:
name: Cypress Tests Results 📖
path: report.xml
reporter: java-junit
fail-on-error: "false"
examplesClean:
name: Clean Example
runs-on: ubuntu-latest
timeout-minutes: 1
needs: [build, examplesResults]
if: always()
strategy:
matrix:
example: ${{fromJson(needs.build.outputs.matrix)}}
steps:
- name: Delete Report XML Artifact
uses: geekyeggo/delete-artifact@v2
id: restore-build
with:
name: report-xml-${{ matrix.example }}
failOnError: false