-
Notifications
You must be signed in to change notification settings - Fork 16
183 lines (148 loc) · 5.83 KB
/
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
179
180
181
182
183
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main, next and v1 branches
on:
push:
branches:
- main
- next
- v1
paths-ignore:
- '**/docs/**'
- '**.md'
pull_request:
types: [opened, synchronize, reopened, edited, ready_for_review]
paths-ignore:
- '**/docs/**'
- '**.md'
concurrency: ci-${{ github.ref }}
jobs:
# This job will run the minimal checks: linting, unit tests and type checking.
BasicChecks:
name: Basic Checks
runs-on: ubuntu-latest
# Do not run if the pull request is a draft
if: ${{ !github.event.pull_request.draft && !contains(github.event.commits[0].message, '[skip build]') }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: '20'
scope: '@farfetch'
cache: 'yarn'
always-auth: true
- name: Install dependencies
run: yarn install --ignore-engines --frozen-lockfile
- name: Lint
run: yarn lint
- name: Unit Tests
run: yarn test --ci
- name: Type checking
run: yarn ci:types
# This job will run integration tests, possibly only the critical ones if the branch is master or next
IntegrationTests:
name: Integration Tests
runs-on: ubuntu-latest
env:
PROXY_TARGET: ${{ secrets.E2E_TESTS_PROXY_TARGET }}
TEST_ACCOUNT_USERNAME: ${{ secrets.E2E_TESTS_ACCOUNT_USERNAME }}
TEST_ACCOUNT_PASSWORD: ${{ secrets.E2E_TESTS_ACCOUNT_PASSWORD }}
# Do not run if the pull request is a draft
if: ${{ !github.event.pull_request.draft && !contains(github.event.commits[0].message, '[skip build]') }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: '20'
scope: '@farfetch'
cache: 'yarn'
always-auth: true
- name: Install dependencies
run: yarn install --ignore-engines --frozen-lockfile
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Update version and build packages
run: yarn ci:release:no-publish && yarn build && yarn build:copy-package-json
- name: Build test application
run: yarn test:e2e:build
- name: Setup host alias
run: |
sudo echo "127.0.0.1 development.blackandwhite-ff.com" | sudo tee -a /etc/hosts
- name: Start server
run: yarn test:e2e:server &
- name: Sleep to wait for server to start
run: sleep 5
- name: Run critical tests
run: yarn test:e2e:run:critical
- name: Run non critical tests
if: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/next' }}
run: yarn test:e2e:run:non-critical
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: tests/e2e/report
retention-days: 30
# This will make a release after the dependant checks are finished and
# it is in a branch that allows publishing (master and next).
Release:
runs-on: ubuntu-latest
# Do not run if the pull request is a draft
if: ${{ !github.event.pull_request.draft && !contains(github.event.commits[0].message, '[skip build]') }}
needs: [BasicChecks, IntegrationTests]
steps:
# Use fetch-depth: 0 so that all tags and branches are fetched
# Use persist-credentials: false so that the make release step uses another personal access
# token which has admin access and can push the version commit without the restriction
# of creating a pull-request.
- uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '20'
scope: '@farfetch'
cache: 'yarn'
always-auth: true
# This is needed for lerna to commit and push the
# new version when making a release
- name: Checkout the source branch in a pull request for lerna
env:
HEAD_REF: ${{ github.head_ref }}
if: ${{ github.event_name == 'pull_request' && startsWith(github.head_ref, 'rc/') }}
run: git checkout "$HEAD_REF"
# This is needed for lerna to commit and push the
# new version when making a release
- name: Checkout the branch for pushes to a branch for lerna
env:
REF_NAME: ${{ github.ref_name }}
if: ${{ github.event_name == 'push' }}
run: git checkout "$REF_NAME"
# Retrieves the commit message to be used in the
# make release step
- name: Get commit message
id: get-commit-message
run: |
COMMIT_MSG=$(git log -1 --pretty=format:"%s")
echo "Commit message is: ${COMMIT_MSG})"
echo ::set-output name=message::${COMMIT_MSG}
- name: Install dependencies
run: yarn install --ignore-engines --frozen-lockfile
# Only make a release if it is a run of the 'main' or 'next' branches
# or a pull request that contains a 'chore: make release' message
- name: Make release
if: |
github.ref_name == 'main' ||
github.ref_name == 'next'
env:
MAKE_RELEASE_COMMIT_MESSAGE: 'chore: make release'
PUBLISH_COMMIT_MESSAGE: 'chore: publish [skip build]'
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.RELEASE_BOT_GIT_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.RELEASE_BOT_GIT_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.RELEASE_BOT_GIT_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.RELEASE_BOT_GIT_EMAIL }}
run: yarn ci:release