-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (125 loc) · 5.05 KB
/
deploy-and-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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Deploy & run E2E
run-name: 'E2E by ${{ github.event.client_payload.actor || github.actor }} to ${{ github.event.client_payload.stack || github.event.inputs.stack }}. Images core: ${{ github.event.client_payload.core-image-tag || github.event.inputs.core-image-tag }} and farajaland: ${{ github.event.client_payload.countryconfig-image-tag || github.event.inputs.countryconfig-image-tag }}'
on:
repository_dispatch:
types: [run_e2e]
workflow_dispatch:
inputs:
core-image-tag:
description: Core DockerHub image tag
required: true
default: 'v1.4.1'
countryconfig-image-tag:
description: Your Country Config DockerHub image tag
required: true
default: 'v1.4.1'
stack:
type: string
description: Stack name
required: true
concurrency:
group: ${{ github.event.client_payload.stack || github.event.inputs.stack }}
cancel-in-progress: true
jobs:
deploy:
uses: ./.github/workflows/deploy.yml
with:
core-image-tag: ${{ github.event.client_payload.core-image-tag || github.event.inputs.core-image-tag }}
countryconfig-image-tag: ${{ github.event.client_payload.countryconfig-image-tag || github.event.inputs.countryconfig-image-tag }}
stack: ${{ github.event.client_payload.stack || github.event.inputs.stack }}
dependencies: false
reset: 'true'
secrets: inherit
discover-tests:
name: Discover test directories
runs-on: ubuntu-22.04
outputs:
test_matrix: ${{ steps.list-tests.outputs.test_matrix }}
steps:
- uses: actions/checkout@v4
with:
repository: 'opencrvs/opencrvs-farajaland'
fetch-depth: 0
- name: Checkout country branch
run: |
git checkout ${{ github.event.client_payload.countryconfig-image-tag || github.event.inputs.countryconfig-image-tag }}
- name: List Test Directories
id: list-tests
run: |
test_dirs=$(find ./e2e/testcases -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | jq -R -s -c 'split("\n")[:-1]')
echo "Test directories: $test_dirs"
echo "test_matrix=$test_dirs" >> $GITHUB_OUTPUT
echo "test_matrix=$test_dirs"
test:
needs: [deploy, discover-tests]
runs-on: ubuntu-22.04
environment: ${{ github.event.client_payload.stack || github.event.inputs.stack }}
strategy:
fail-fast: false
matrix:
test_dir: ${{ fromJson(needs.discover-tests.outputs.test_matrix) }}
steps:
- uses: actions/checkout@v4
with:
repository: 'opencrvs/opencrvs-farajaland'
fetch-depth: 0
- name: Checkout country branch
run: |
git checkout ${{ github.event.client_payload.countryconfig-image-tag || github.event.inputs.countryconfig-image-tag }}
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Check for Spec Files
id: check-specs
run: |
if ls ./e2e/testcases/${{ matrix.test_dir }}/*.spec.ts > /dev/null 2>&1; then
echo "::set-output name=has_spec_files::true"
else
echo "::set-output name=has_spec_files::false"
fi
- name: Cache Node.js dependencies
uses: actions/cache@v4
with:
path: |
node_modules
~/.cache/yarn/v6
key: node-${{ hashFiles('**/yarn.lock', format('{0}/{1}',matrix.package,'package.json')) }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Dependencies
if: steps.check-specs.outputs.has_spec_files == 'true'
run: yarn
- name: Install Playwright Browsers
if: steps.check-specs.outputs.has_spec_files == 'true'
run: npx playwright install --with-deps
- name: Run Playwright Tests
if: steps.check-specs.outputs.has_spec_files == 'true'
run: npx playwright test ./e2e/testcases/${{ matrix.test_dir }}
env:
DOMAIN: '${{ github.event.client_payload.stack || inputs.stack }}.${{ vars.DOMAIN }}'
- uses: actions/upload-artifact@v4
if: always() && steps.check-specs.outputs.has_spec_files == 'true'
with:
name: playwright-report-${{ github.event.client_payload.stack || github.event.inputs.stack }}-${{ matrix.test_dir }}
path: playwright-report/
retention-days: 30
get-previous-run:
runs-on: ubuntu-latest
outputs:
previous_run_result: ${{ steps.set-output.outputs.result }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Previous Run Conclusion
id: get-previous-conclusion
run: |
previous_conclusion=$(gh run list --limit 1 --status=completed --workflow="Deploy & run E2E" --json conclusion -q '.[0].conclusion')
echo "PREVIOUS_CONCLUSION=$previous_conclusion" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Set Output Based on Conclusion
id: set-output
run: |
echo "result=$PREVIOUS_CONCLUSION" >> $GITHUB_OUTPUT