This repository has been archived by the owner on May 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
340 lines (296 loc) · 11.3 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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
name: CI
defaults:
run: {shell: bash}
on:
push:
branches: [main, feature.*]
tags: ['**']
pull_request:
jobs:
dart_tests:
name: "Dart tests | Dart ${{ matrix.dart_channel }} | ${{ matrix.os }}"
runs-on: "${{ matrix.os }}"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
dart_channel: [stable]
include: [{os: ubuntu-latest, dart_channel: dev}]
steps:
- uses: actions/checkout@v3
- uses: frenck/action-setup-yq@v1
with: {version: v4.30.5} # frenck/action-setup-yq#35
- uses: bufbuild/buf-setup-action@v1.13.1
with: {github_token: "${{ github.token }}"}
- uses: dart-lang/setup-dart@v1
with: {sdk: "${{ matrix.dart_channel }}"}
- name: Check out Dart Sass only if linked in the PR description
uses: sass/clone-linked-repo@v1
with:
repo: sass/dart-sass
path: build/dart-sass
default-ref: null
- name: Link the embedded compiler to Dart Sass
run: |
if [[ -d build/dart-sass ]]; then
yq -i '
.dependency_overrides.sass = {"path": "build/dart-sass"} |
.dependency_overrides.sass_api = {"path": "build/dart-sass/pkg/sass_api"}
' pubspec.yaml
fi
shell: bash
- name: Check out embedded Sass protocol
uses: sass/clone-linked-repo@v1
with: {repo: sass/embedded-protocol, path: build/embedded-protocol}
- run: dart pub get
- run: dart run grinder protobuf
env: {UPDATE_SASS_PROTOCOL: false}
- run: dart run grinder pkg-standalone-dev
- name: Run tests
run: dart run test -r expanded
# The versions should be kept up-to-date with the latest LTS Node releases.
# They next need to be rotated October 2021. See
# https://github.com/nodejs/Release.
sass_spec:
name: 'JS API Tests | Node ${{ matrix.node_version }} | ${{ matrix.os }}'
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows, macos]
node_version: [18]
include:
# Include LTS versions on Ubuntu
- os: ubuntu
node_version: 16
- os: ubuntu
node_version: 14
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
with: {sdk: stable}
- uses: frenck/action-setup-yq@v1
with: {version: v4.30.5} # frenck/action-setup-yq#35
- uses: bufbuild/buf-setup-action@v1.13.1
with: {github_token: "${{ github.token }}"}
- name: Check out Dart Sass only if linked in the PR description
uses: sass/clone-linked-repo@v1
with:
repo: sass/dart-sass
path: build/dart-sass
# Unless we're cutting a release, run the main branch of Dart Sass
# against the main branch of sass-spec so that we don't need to make
# an empty commit to this repo every time we update those two.
default-ref: ${{ !startsWith(github.ref, 'refs/tags/') && 'main' || null }}
- name: Link the embedded compiler to Dart Sass
run: |
if [[ -d build/dart-sass ]]; then
yq -i '
.dependency_overrides.sass = {"path": "build/dart-sass"} |
.dependency_overrides.sass_api = {"path": "build/dart-sass/pkg/sass_api"}
' pubspec.yaml
fi
shell: bash
- name: Check out embedded Sass protocol
uses: sass/clone-linked-repo@v1
with: {repo: sass/embedded-protocol, path: build/embedded-protocol}
- name: Check out the embedded host
uses: sass/clone-linked-repo@v1
with: {repo: sass/embedded-host-node}
- name: Check out the JS API definition
uses: sass/clone-linked-repo@v1
with: {repo: sass/sass, path: language}
- name: Initialize embedded host
run: |
npm install
npm run init -- --protocol-path=../build/embedded-protocol \
--compiler-path=.. --api-path=../language
npm run compile
mv {`pwd`/,dist/}lib/src/vendor/dart-sass-embedded
working-directory: embedded-host-node
- name: Check out sass-spec
uses: sass/clone-linked-repo@v1
with: {repo: sass/sass-spec}
- name: Install sass-spec dependencies
run: npm install
working-directory: sass-spec
- name: Version info
run: |
path=embedded-host-node/dist/lib/src/vendor/dart-sass-embedded/dart-sass-embedded
if [[ -f "$path.cmd" ]]; then "./$path.cmd" --version
elif [[ -f "$path.bat" ]]; then "./$path.bat" --version
elif [[ -f "$path.exe" ]]; then "./$path.exe" --version
else "./$path" --version
fi
- name: Run tests
run: npm run js-api-spec -- --sassPackage ../embedded-host-node --sassSassRepo ../language
working-directory: sass-spec
static_analysis:
name: Static analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: frenck/action-setup-yq@v1
with: {version: v4.30.5} # frenck/action-setup-yq#35
- uses: bufbuild/buf-setup-action@v1.13.1
with: {github_token: "${{ github.token }}"}
- uses: dart-lang/setup-dart@v1
- name: Check out Dart Sass only if linked in the PR description
uses: sass/clone-linked-repo@v1
with:
repo: sass/dart-sass
path: build/dart-sass
default-ref: null
- name: Link the embedded compiler to Dart Sass
run: |
if [[ -d build/dart-sass ]]; then
yq -i '
.dependency_overrides.sass = {"path": "build/dart-sass"} |
.dependency_overrides.sass_api = {"path": "build/dart-sass/pkg/sass_api"}
' pubspec.yaml
fi
shell: bash
- name: Check out embedded Sass protocol
uses: sass/clone-linked-repo@v1
with: {repo: sass/embedded-protocol, path: build/embedded-protocol}
- run: dart pub get
- run: dart run grinder protobuf
env: {UPDATE_SASS_PROTOCOL: false}
- name: Analyze dart
run: dart analyze --fatal-warnings ./
format:
name: Code formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- run: dart format --fix .
- run: git diff --exit-code
deploy_github_linux:
name: "Deploy Github: linux-ia32, linux-x64"
runs-on: ubuntu-latest
needs: [dart_tests, sass_spec, static_analysis, format]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass-embedded'"
steps:
- uses: actions/checkout@v3
- uses: bufbuild/buf-setup-action@v1.13.1
with: {github_token: "${{ github.token }}"}
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- run: dart run grinder protobuf
- name: Deploy
run: dart run grinder pkg-github-release pkg-github-linux-ia32 pkg-github-linux-x64
env: {GH_BEARER_TOKEN: "${{ github.token }}"}
deploy_github_linux_qemu:
name: "Deploy Github: linux-${{ matrix.arch }}"
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch: arm
platform: linux/arm/v7
- arch: arm64
platform: linux/arm64
needs: [deploy_github_linux]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass-embedded'"
steps:
- uses: actions/checkout@v3
- uses: bufbuild/buf-setup-action@v1.13.1
with: {github_token: "${{ github.token }}"}
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- run: dart run grinder protobuf
- uses: docker/setup-qemu-action@v2
- name: Deploy
run: |
docker run --rm \
--env "GH_BEARER_TOKEN=$GH_BEARER_TOKEN" \
--platform ${{ matrix.platform }} \
--volume "$PWD:$PWD" \
--workdir "$PWD" \
docker.io/library/dart:latest \
/bin/sh -c "dart pub get && dart run grinder pkg-github-linux-${{ matrix.arch }}"
env: {GH_BEARER_TOKEN: "${{ github.token }}"}
deploy_github:
name: "Deploy Github: ${{ matrix.platform }}"
runs-on: ${{ matrix.runner }}
needs: [deploy_github_linux]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass-embedded'"
strategy:
matrix:
include:
- runner: macos-latest
platform: macos-x64
architecture: x64
- runner: self-hosted
platform: macos-arm64
architecture: arm64
- runner: windows-latest
platform: windows
architecture: x64
steps:
- uses: actions/checkout@v3
- uses: bufbuild/buf-setup-action@v1.13.1
with: {github_token: "${{ github.token }}"}
- uses: dart-lang/setup-dart@v1
# Workaround for dart-lang/setup-dart#59
with:
architecture: ${{ matrix.architecture }}
- run: dart pub get
- run: dart run grinder protobuf
- name: Deploy
run: dart run grinder pkg-github-${{ matrix.platform }}
env: {GH_BEARER_TOKEN: "${{ github.token }}"}
deploy_homebrew:
name: "Deploy Homebrew"
runs-on: ubuntu-latest
needs: [dart_tests, sass_spec, static_analysis, format]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass-embedded'"
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- name: Deploy
run: dart run grinder pkg-homebrew-update
env:
GH_TOKEN: "${{ secrets.GH_TOKEN }}"
GH_USER: sassbot
release_embedded_host:
name: "Release Embedded Host"
runs-on: ubuntu-latest
needs: [deploy_github_linux, deploy_github_linux_qemu, deploy_github]
if: "startsWith(github.ref, 'refs/tags/') && github.repository == 'sass/dart-sass-embedded'"
steps:
- uses: actions/checkout@v3
with:
repository: sass/embedded-host-node
token: ${{ secrets.GH_TOKEN }}
- name: Get version
id: version
run: echo "::set-output name=version::${GITHUB_REF##*/}"
- name: Update version
run: |
# Update binary package versions
for dir in $(ls npm); do
cat "npm/$dir/package.json" |
jq --arg version ${{ steps.version.outputs.version }} '
.version |= $version
' > package.json.tmp &&
mv package.json.tmp "npm/$dir/package.json"
done
# Update main package version and dependencies on binary packages
cat package.json |
jq --arg version ${{ steps.version.outputs.version }} '
.version |= $version |
."compiler-version" |= $version |
.optionalDependencies = (.optionalDependencies | .[] |= $version)
' > package.json.tmp &&
mv package.json.tmp package.json
curl https://raw.githubusercontent.com/sass/dart-sass/${{ steps.version.outputs.version }}/CHANGELOG.md > CHANGELOG.md
shell: bash
- uses: EndBug/add-and-commit@v8
with:
author_name: Sass Bot
author_email: sass.bot.beep.boop@gmail.com
message: Update compiler version and release
tag: ${{ steps.version.outputs.version }}