This repository has been archived by the owner on Oct 28, 2024. It is now read-only.
forked from XGovFormBuilder/digital-form-builder
-
Notifications
You must be signed in to change notification settings - Fork 1
144 lines (134 loc) · 5.05 KB
/
branch--lint-unit-and-smoke-test.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
144
name: Branch QA
on:
pull_request:
branches:
- master
- main
paths-ignore:
- "docs/**"
- "**/README.md"
- "python/**"
workflow_dispatch:
jobs:
lint-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
app: [designer, runner, model]
name: lint-and-test-${{matrix.app}}
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "12.x"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- name: Configure yarn caching
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install
- name: Check existing forms
if: ${{ matrix.app == 'runner' }}
run: yarn runner check-forms
- name: Build dependencies
run: yarn build:dependencies
- name: Lint
run: yarn ${{matrix.app}} lint
- name: Test
run: yarn ${{matrix.app}} test-cov
- name: Upload test results artifacts
uses: actions/upload-artifact@v2
if: ${{ success() || failure() }}
with:
name: test-results-${{matrix.app}}
path: ${{matrix.app}}/test-results
retention-days: 14
- name: Upload test coverage artifacts
uses: actions/upload-artifact@v2
if: ${{ success() || failure() }}
with:
name: test-coverage-${{matrix.app}}
path: ${{matrix.app}}/test-coverage
retention-days: 14
smoke-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "12.x"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Docker compose pull
run: docker-compose pull
# DAYOFYEAR key is used to rotate docker-layer-caching to avoid the layers dandle issue
# see https://github.com/satackey/action-docker-layer-caching/issues/55
# if you change this, please remember to apply the same changes to main--lint-unit-build-and-publish-images.yml
# so main branch cache can be shared with branches
- run: echo "DAYOFYEAR = $(date +%j)"
- run: echo "DAYOFYEAR=$(date +%j)" >> $GITHUB_ENV
- name: Docker layer caching
uses: satackey/action-docker-layer-caching@v0.0.11
continue-on-error: true
with:
key: digital-form-builder-${{ env.DAYOFYEAR }}-{hash}
restore-keys: |
digital-form-builder-${{ env.DAYOFYEAR }}
- name: Create .env for ${{ matrix.app }} workspace
run: |
touch ./${{ matrix.app }}/.env
echo LAST_TAG_GH=2.0.${{ github.run_number }}-rc >> ./${{ matrix.app }}/.env
echo LAST_COMMIT_GH=${{ github.sha }} >> ./${{ matrix.app }}/.env
cat ./${{ matrix.app }}/.env
- name: Docker compose build
run: |
docker-compose build --parallel
- name: Docker compose up
run: docker-compose up -d
- name: Install smoke tests dependencies
run: yarn workspaces focus @xgovformbuilder/test
- name: Check designer container is running
run: |
docker ps
docker run --network container:designer appropriate/curl -4 --retry 10 --retry-connrefused --retry-delay 10 http://localhost:3000/
- name: Check runner container is running
run: |
docker ps
docker run --network container:runner appropriate/curl -4 --retry 10 --retry-connrefused --retry-delay 10 http://localhost:3009/
- name: Smoke Test
run: |
yarn smoke-tests/designer smoke-test-headless
ls -lah smoke-tests/designer/reports/
- name: Run pa11y
run: yarn designer dlx pa11y-ci
- name: Run Lighthouse on urls and validate with lighthouserc
uses: treosh/lighthouse-ci-action@v8
with:
configPath: "./lighthouserc.js"
uploadArtifacts: true
- name: "Tar files"
if: ${{ success() || failure() }}
run: tar -cvf smoke-tests.tar smoke-tests/designer/reports
- uses: actions/upload-artifact@v2
if: ${{ success() || failure() }}
with:
name: smoke-tests
path: smoke-tests.tar
retention-days: 14