-
Notifications
You must be signed in to change notification settings - Fork 1.8k
195 lines (184 loc) · 6.69 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
# 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:
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
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: stable
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=Cargo.toml --bin relay ./test-project/relay.json
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-compiler-linux-x64
packages: musl-tools
features: vendored
- target: x86_64-apple-darwin
os: macos-latest
build-name: relay
artifact-name: relay-compiler-macos-x64
- target: aarch64-apple-darwin
os: macos-latest
build-name: relay
artifact-name: relay-compiler-macos-arm64
- target: x86_64-pc-windows-msvc
os: windows-latest
build-name: relay.exe
artifact-name: relay-compiler-win-x64
runs-on: ${{ matrix.target.os }}
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
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
- uses: actions-rs/cargo@v1
with:
command: build
# add --locked back when we have a better way to ensure it's up to date
args: --manifest-path=compiler/Cargo.toml --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-compiler-linux-x64
uses: actions/download-artifact@v2
with:
name: relay-compiler-linux-x64
path: artifacts/linux-x64
- name: Download artifact relay-compiler-macos-x64
uses: actions/download-artifact@v2
with:
name: relay-compiler-macos-x64
path: artifacts/macos-x64
- name: Download artifact relay-compiler-macos-arm64
uses: actions/download-artifact@v2
with:
name: relay-compiler-macos-arm64
path: artifacts/macos-arm64
- name: Download artifact relay-compiler-win-x64
uses: actions/download-artifact@v2
with:
name: relay-compiler-win-x64
path: artifacts/win-x64
- name: Mark binaries as executable
working-directory: artifacts
run: |
chmod +x linux-x64/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}}