-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (87 loc) · 3.66 KB
/
reusable-e2e.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: E2E
on:
workflow_call:
env:
E2E_DIR: projects/ngx-meta/e2e
COVERAGE_DIR: coverage/ngx-meta
# 👇 Keep in sync with example apps workflow
COVERAGE_ARTIFACT_NAME_SUFFIX: -coverage
# 👇 Keep in sync with example apps workflow
EXAMPLE_APP_ARTIFACT_NAME_SUFFIX: -example-app
# 👇 Keep in sync with e2e and coverage workflows
COVERAGE_REPORT_ARTIFACT_NAME_SUFFIX: -coverage-report
jobs:
load-config:
name: Load CI/CD configuration
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
example-apps-version-aliases: ${{ steps.load-config.outputs.example-apps-version-aliases }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Load CI/CD configuration
id: load-config
uses: ./.github/actions/config
e2e:
name: E2E tests - Angular ${{ matrix.cli-version-alias }}
needs: load-config
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
cli-version-alias: ${{ fromJSON(needs.load-config.outputs.example-apps-version-aliases) }}
env:
EXAMPLE_APP_DIR: projects/ngx-meta/example-apps/apps/${{ matrix.cli-version-alias }}
defaults:
run:
working-directory: ${{ env.E2E_DIR }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Download example app with coverage instrumentation
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: ngx-meta${{ env.EXAMPLE_APP_ARTIFACT_NAME_SUFFIX }}-${{ matrix.cli-version-alias }}${{ env.COVERAGE_ARTIFACT_NAME_SUFFIX }}
path: ${{ env.EXAMPLE_APP_DIR }}
- name: Setup pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
cache: pnpm
cache-dependency-path: ${{ env.E2E_DIR }}/pnpm-lock.yaml
node-version-file: .node-version # should be one compatible with Angular example app
- name: Configure Cypress cache directory
run: echo "CYPRESS_CACHE_FOLDER=$HOME/.cache/Cypress" >> "$GITHUB_ENV"
- name: Cypress cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
env:
cache-name: ngx-meta-e2e-cypress
e2e_lockfile_hash: ${{ hashFiles(format('{0}/pnpm-lock.yaml', env.E2E_DIR)) }}
with:
path: ${{ env.CYPRESS_CACHE_FOLDER }}
key: ${{ env.cache-name }}-${{ env.e2e_lockfile_hash }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Serve app
run: pnpm run ci:serve &
working-directory: ${{ env.EXAMPLE_APP_DIR }}
- name: Cypress run
uses: cypress-io/github-action@0da3c06ed8217b912deea9d8ee69630baed1737e # v6.7.6
env:
COVERAGE_JSON_REPORT_NAME: e2e-${{ matrix.cli-version-alias }}.json
with:
working-directory: ${{ env.E2E_DIR }}
browser: chrome
# 👇 Action doesn't support pnpm caching right now
# https://github.com/cypress-io/github-action/tree/v6.6.1?tab=readme-ov-file#pnpm
# Given we're doing caching manually, installing apart to leverage cache
install: false
- name: Upload coverage report
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
if: failure() || success()
with:
name: ngx-meta-e2e-${{ matrix.cli-version-alias }}${{ env.COVERAGE_REPORT_ARTIFACT_NAME_SUFFIX }}
path: ${{ env.COVERAGE_DIR }}/*.json
retention-days: 5