-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (146 loc) · 5.48 KB
/
applicant-ci.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Applicant CI
on:
pull_request:
branches:
- develop
- feat/**
- feature/**
paths:
- "packages/applicant/**"
- "packages/gap-web-ui/**"
- ".github/workflows/applicant-ci.yml"
- "package.json"
- "yarn.lock"
jobs:
install:
name: Install dependencies
runs-on: ubuntu-latest
outputs:
gap-web-ui-hash: ${{ steps.gap-web-ui-hash.outputs.name }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Generate gap-web-ui hash
id: gap-web-ui-hash
run: |
NAME=${{ hashFiles('**/packages/gap-web-ui/**/*.js', '**/packages/gap-web-ui/**/*.jsx', '**/packages/gap-web-ui/**/*.ts', '**/packages/gap-web-ui/**/*.tsx') }}
echo "name=$NAME" >> $GITHUB_OUTPUT
- name: Read .nvmrc
id: nvm
run: echo "name=NVMRC::$(cat .nvmrc)" >> $GITHUB_OUTPUT
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
- name: Save node modules
uses: actions/cache/save@v3
with:
path: |
${{ github.workspace }}/node_modules
${{ github.workspace }}/packages/applicant/node_modules
key: ${{ github.sha }}
- name: Restore gap-web-ui cache
id: gap-web-ui-cache
uses: actions/cache/restore@v3
with:
path: ${{ github.workspace }}/packages/gap-web-ui/dist
key: gap-web-ui-${{ steps.gap-web-ui-hash.outputs.name }}
- name: Build gap-web-ui
if: steps.gap-web-ui-cache.outputs.cache-hit != 'true'
run: yarn workspace gap-web-ui build
- name: Save gap-web-ui cache
if: steps.gap-web-ui-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ${{ github.workspace }}/packages/gap-web-ui/dist
key: gap-web-ui-${{ steps.gap-web-ui-hash.outputs.name }}
build:
name: Build app
needs: install
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Generate source files hash
id: source-file-hash
run: |
NAME=${{ hashFiles('**/packages/applicant/src/**/*.js', '**/packages/applicant/src/**/*.jsx', '**/packages/applicant/src/**/*.ts', '**/packages/applicant/src/**/*.tsx') }}
echo "name=$NAME" >> $GITHUB_OUTPUT
- name: Generate yarn lock hash
id: yarn-lock-hash
run: |
NAME=${{ hashFiles('**/yarn.lock') }}
echo "name=$NAME" >> $GITHUB_OUTPUT
- name: Generate .env files
run: cp packages/applicant/.env.example packages/applicant/.env
- name: Read .nvmrc
id: nvm
run: echo "name=NVMRC::$(cat .nvmrc)" >> $GITHUB_OUTPUT
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: 'yarn'
- name: Restore gap-web-ui cache
id: gap-web-ui-cache
uses: actions/cache/restore@v3
with:
path: ${{ github.workspace }}/packages/gap-web-ui/dist
key: gap-web-ui-${{ needs.install.outputs.gap-web-ui-hash }}
- name: Restore node modules
uses: actions/cache/restore@v3
with:
path: |
${{ github.workspace }}/node_modules
${{ github.workspace }}/packages/applicant/node_modules
key: ${{ github.sha }}
# Based on steps described here - https://nextjs.org/docs/pages/building-your-application/deploying/ci-build-caching#github-actions
- name: Next applicant cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/packages/applicant/.next/cache
key: applicant-next-cache-${{ steps.yarn-lock-hash.outputs.name }}-${{ steps.source-file-hash.outputs.name }}
restore-keys: applicant-next-cache-${{ steps.yarn-lock-hash.outputs.name }}-
- name: Build application
run: yarn workspace applicant build
- name: Lint files
run: yarn workspace applicant lint
test:
name: Test app
runs-on: ubuntu-latest
needs: install
strategy:
matrix:
shard: [1, 2, 3, 4]
fail-fast: false
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Generate gap-web-ui hash
id: gap-web-ui-hash
run: |
NAME=${{ hashFiles('**/packages/gap-web-ui/**/*.js', '**/packages/gap-web-ui/**/*.jsx', '**/packages/gap-web-ui/**/*.ts', '**/packages/gap-web-ui/**/*.tsx') }}
echo "name=$NAME" >> $GITHUB_OUTPUT
- name: Setup node
uses: actions/setup-node@v3
with:
cache: 'yarn'
- name: Restore node modules
uses: actions/cache/restore@v3
with:
path: |
${{ github.workspace }}/node_modules
${{ github.workspace }}/packages/applicant/node_modules
key: ${{ github.sha }}
- name: Restore gap-web-ui cache
uses: actions/cache/restore@v3
with:
path: ${{ github.workspace }}/packages/gap-web-ui/dist
key: gap-web-ui-${{ steps.gap-web-ui-hash.outputs.name }}
- name: Generate .env files
run: cp packages/applicant/.env.example packages/applicant/.env
- name: Run tests
run: yarn jest --selectProjects applicant --runInBand --ci --shard=${{ matrix.shard }}/${{ strategy.job-total }}