-
-
Notifications
You must be signed in to change notification settings - Fork 7
125 lines (106 loc) · 4.28 KB
/
continuous-integration-javascript.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
on:
merge_group:
types:
- checks_requested
pull_request:
# We do not run tests on master as the changes were already tested when opening a PR,
# and we require every PR to be up-to-date before merging it to master.
types:
- opened
- synchronize
- reopened
env:
CI: true
NODE_OPTIONS: --max-old-space-size=6144
BABEL_DISABLE_CACHE: '1'
jobs:
javascript-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# We support only Node.js versions with "LTS" and "Current" status (no "Maintenance").
# See: https://nodejs.dev/en/about/releases/
# See: https://github.com/nodejs/Release
node-version: [20.x, 21.x, 22.x]
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4.2.2
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
fetch-depth: 0
# https://github.com/dorny/paths-filter
- uses: dorny/paths-filter@v3.0.2
id: paths-filter
with:
filters: .github/filters.js.yaml
# https://github.com/actions/setup-node
- name: Use Node.js ${{ matrix.node-version }}
if: steps.paths-filter.outputs.src == 'true'
uses: actions/setup-node@v4.1.0
with:
node-version: ${{ matrix.node-version }}
- name: Get Yarn cache directory path
if: steps.paths-filter.outputs.src == 'true'
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
# https://github.com/actions/cache
- name: Restore Yarn cache
if: steps.paths-filter.outputs.src == 'true'
uses: actions/cache@v4.2.0
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-cache-folder-${{ hashFiles('**/yarn.lock', '.yarnrc.yml') }}
restore-keys: |
yarn-cache-folder-
# https://github.com/dtolnay/rust-toolchain
- uses: dtolnay/rust-toolchain@stable
if: steps.paths-filter.outputs.src == 'true'
- name: Install Yarn dependencies
if: steps.paths-filter.outputs.src == 'true'
run: ./x install -- --immutable
- name: Check Yarn constraints
if: steps.paths-filter.outputs.src == 'true'
run: yarn constraints # TODO: move to `./x install` (?)
# We are purposefully expecting zero warnings in the output to make sure flowtests are
# working as expected (Flow returns warnings for unused suppression comments).
- name: Run Flow check
if: steps.paths-filter.outputs.src == 'true'
run: ./x flow -- --max-warnings=0
# TypeScript can be used in one of two ways - as a linter, or as a build tool.
# We are using it as a linter on a monorepo level and as a build tool on individual packages.
- name: Run TypeScript check
if: steps.paths-filter.outputs.src == 'true'
run: yarn tsc --allowJs --project tsconfig.json # TODO: `./x ts`
- name: Run Eslint check
if: steps.paths-filter.outputs.src == 'true'
run: ./x lints
- name: Run Jest tests
if: steps.paths-filter.outputs.src == 'true'
run: ./x tests
- name: Run monorepo scanner
if: steps.paths-filter.outputs.src == 'true'
run: ./x scanner
# Runs the Relay Compiler for the whole monorepo and exit if there are new changes
# (meaning the generated files are not up-to-date).
- name: Run Relay check
if: steps.paths-filter.outputs.src == 'true'
run: ./x relay -- --validate
- name: Make sure there are no file changes generated by our scripts
run: git diff --exit-code
# The purpose of this job is to wait for the completion of the `javascript-test` jobs (matrix)
# and evaluate whether the run was successful or not. This is useful when configuring the
# required jobs in GitHub UI (we can require just this one job instead of all the jobs in
# the test matrix).
javascript-test-results:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [javascript-test]
steps:
- run: |
result="${{ needs.javascript-test.result }}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi