-
Notifications
You must be signed in to change notification settings - Fork 1.8k
252 lines (239 loc) · 8.54 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
name: CI
on: [push, pull_request]
jobs:
vscode-extension-lint:
name: VSCode Extension Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./vscode-extension
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts
- name: ESLint
run: yarn run lint
- name: Prettier
run: yarn run prettier-check
- name: Typecheck
run: yarn run typecheck
js-tests:
name: JS Tests (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run tests
run: yarn run jest
js-lint:
name: JS Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts
- name: Test dependencies
run: yarn run test-dependencies
- name: Lint
run: yarn run lint
- name: Prettier
run: yarn run prettier-check
typecheck:
name: Flow Typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts
- name: Flow
run: yarn run typecheck
rust-tests:
name: Rust Tests (${{ matrix.os }})
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.58.0
override: true
- uses: actions-rs/cargo@v1
with:
command: test
# add --locked back when we have a better way to ensure it's up to date
args: --manifest-path=compiler/Cargo.toml
- name: "Build test project"
run: cargo run --manifest-path=../crates/relay-bin/Cargo.toml
working-directory: ./compiler/test-project
rust-lint:
name: Rust Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-06-15
override: true
components: rustfmt
- name: "rustfmt"
run: grep -r --include "*.rs" --files-without-match "@generated" crates | xargs rustfmt --check --config="skip_children=true"
working-directory: ./compiler/
build-compiler:
name: Build Rust Compiler (${{ matrix.target.os }})
strategy:
matrix:
target:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
build-name: relay
artifact-name: relay-bin-linux-x64
packages: musl-tools
features: vendored
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
build-name: relay
artifact-name: relay-bin-linux-arm64
features: vendored
cross: true
- target: x86_64-apple-darwin
os: macos-latest
build-name: relay
artifact-name: relay-bin-macos-x64
- target: aarch64-apple-darwin
os: macos-latest
build-name: relay
artifact-name: relay-bin-macos-arm64
- target: x86_64-pc-windows-msvc
os: windows-latest
build-name: relay.exe
artifact-name: relay-bin-win-x64
runs-on: ${{ matrix.target.os }}
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.58.0
override: true
target: ${{ matrix.target.target }}
- uses: actions/setup-node@v2
if: github.event_name == 'push' && github.repository == 'facebook/relay' && github.ref == 'refs/heads/main'
with:
node-version: 16.x
cache: 'yarn'
- name: Install dependencies
if: github.event_name == 'push' && github.repository == 'facebook/relay' && github.ref == 'refs/heads/main'
run: yarn install --frozen-lockfile --ignore-scripts
- name: Set the compiler version when releasing the `main` branch
if: github.event_name == 'push' && github.repository == 'facebook/relay' && github.ref == 'refs/heads/main'
run: yarn gulp setCompilerMainVersion
env:
RELEASE_COMMIT_SHA: ${{ github.sha }}
- name: Install packages
if: matrix.target.os == 'ubuntu-latest' && matrix.target.packages
run: sudo apt install ${{ matrix.target.packages }} -y
- name: Install cross
if: matrix.target.cross
uses: actions-rs/cargo@v1
with:
command: install
args: cross
# Current published version of cross only works correctly if run from compiler directory
# See related issue https://github.com/cross-rs/cross/issues/615
# actions-rs/cargo@v1 does not support this option https://github.com/actions-rs/cargo/pull/59
# Either we need to install cross from git or manually run cargo / cross instead of using action
- name: Build project
working-directory: compiler
run: ${{ matrix.target.cross && 'cross' || 'cargo' }} build --release --target ${{ matrix.target.target }} ${{ matrix.target.features && '--features' }} ${{ matrix.target.features }}
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.target.artifact-name }}
path: compiler/target/${{ matrix.target.target }}/release/${{ matrix.target.build-name }}
main-release:
name: Publish to NPM
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.repository == 'facebook/relay'
needs: [js-tests, js-lint, typecheck, rust-tests, build-compiler]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14.x
registry-url: https://registry.npmjs.org/
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts
- name: Download artifact relay-bin-linux-x64
uses: actions/download-artifact@v2
with:
name: relay-bin-linux-x64
path: artifacts/linux-x64
- name: Download artifact relay-bin-linux-arm64
uses: actions/download-artifact@v2
with:
name: relay-bin-linux-arm64
path: artifacts/linux-arm64
- name: Download artifact relay-bin-macos-x64
uses: actions/download-artifact@v2
with:
name: relay-bin-macos-x64
path: artifacts/macos-x64
- name: Download artifact relay-bin-macos-arm64
uses: actions/download-artifact@v2
with:
name: relay-bin-macos-arm64
path: artifacts/macos-arm64
- name: Download artifact relay-bin-win-x64
uses: actions/download-artifact@v2
with:
name: relay-bin-win-x64
path: artifacts/win-x64
- name: Mark binaries as executable
working-directory: artifacts
run: |
chmod +x linux-x64/relay
chmod +x linux-arm64/relay
chmod +x macos-x64/relay
chmod +x macos-arm64/relay
- name: Build latest (main) version
if: github.ref == 'refs/heads/main'
run: yarn gulp mainrelease
env:
RELEASE_COMMIT_SHA: ${{ github.sha }}
- name: Build release version
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
run: yarn gulp release
- name: Publish to npm
if: github.ref == 'refs/heads/main' || github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
run: |
for pkg in dist/*; do
npm publish "$pkg" ${TAG}
done
env:
TAG: ${{ github.ref == 'refs/heads/main' && '--tag=main' || ((contains(github.ref_name, '-rc.') && '--tag=dev') || '' )}}
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}