Skip to content

Commit 4fd8416

Browse files
authored
ci: clarity-js (#150)
* ci: npm publish clarinet-js, add build ci * ci: add package-lock * chore: fix formatting * ci: update working_dir, run tests * chore: fix npm script * ci: compress node artifact * ci: comment out tests for now * ci: update clarity-js cargo file on release
1 parent cf29e00 commit 4fd8416

File tree

6 files changed

+2933
-37
lines changed

6 files changed

+2933
-37
lines changed

.github/workflows/ci.yaml

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -131,41 +131,48 @@ jobs:
131131
matrix:
132132
include:
133133
- os: ubuntu-latest
134-
platform: linux-x64
134+
platform: linux
135135
target: x86_64-unknown-linux-gnu
136136
linker_package:
137137
cc: ""
138+
architecture: x64
138139
# To be uncommented later when adding new distros
139140
# - os: ubuntu-latest
140-
# platform: linux-arm64
141+
# platform: linux
141142
# target: aarch64-unknown-linux-gnu
142143
# linker_package: gcc-aarch64-linux-gnu
143144
# cc: aarch64-linux-gnu-gcc
145+
# architecture: arm64
144146
# - os: ubuntu-latest
145-
# platform: linux-armv7
147+
# platform: linux
146148
# target: armv7-unknown-linux-gnueabihf
147149
# linker_package: gcc-arm-linux-gnueabihf
148150
# cc: arm-linux-gnueabihf-gcc
151+
# architecture: armv7l
149152
# - os: ubuntu-latest
150-
# platform: linux-musl-x64
153+
# platform: linux
151154
# target: x86_64-unknown-linux-musl
152155
# linker_package:
153156
# cc: musl-gcc
157+
# architecture: x64
154158
- os: windows-latest
155-
platform: windows-x64
159+
platform: windows
156160
target: x86_64-pc-windows-msvc
157161
linker_package:
158162
cc: ""
163+
architecture: x64
159164
- os: macos-latest
160-
platform: macos-x64
165+
platform: darwin
161166
target: x86_64-apple-darwin
162167
linker_package:
163168
cc: ""
169+
architecture: x64
164170
# - os: macos-latest
165-
# platform: macos-aarch64-m1
171+
# platform: darwin
166172
# target: aarch64-apple-darwin
167173
# linker_package:
168174
# cc: ""
175+
# architecture: arm64
169176

170177
steps:
171178
- name: Configure git to use LF (Windows)
@@ -187,6 +194,14 @@ jobs:
187194
profile: minimal
188195
override: true
189196

197+
- name: Install and cache Node
198+
uses: actions/setup-node@v2
199+
with:
200+
node-version: '14'
201+
architecture: ${{ matrix.architecture }}
202+
cache: npm
203+
cache-dependency-path: node-bindings/package-lock.json
204+
190205
- name: Install wix (Windows)
191206
if: matrix.os == 'windows-latest'
192207
run: cargo install cargo-wix
@@ -206,11 +221,11 @@ jobs:
206221
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
207222

208223
# To be uncommented later when adding new distros
209-
# - name: Install ${{ matrix.platform }} linker
210-
# if: matrix.platform == 'linux-arm64' || matrix.platform == 'linux-armv7' || matrix.platform == 'linux-musl-x64'
224+
# - name: Install ${{ matrix.platform }}-${{ matrix.architecture }} linker
225+
# if: ${{ matrix.platform }}-${{ matrix.architecture }} == 'linux-arm64' || ${{ matrix.platform }}-${{ matrix.architecture }} == 'linux-armv7' || ${{ matrix.platform }}-${{ matrix.architecture }} == 'linux-musl-x64'
211226
# run: sudo apt-get update && sudo apt-get install -y ${{ matrix.linker_package }}
212227

213-
- name: Build
228+
- name: Build - Cargo
214229
run: cargo build --release --locked --target ${{ matrix.target }}
215230
# To be uncommented later when adding new distros
216231
# env:
@@ -222,6 +237,12 @@ jobs:
222237
# CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: ${{ matrix.cc }}
223238
# CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER: ${{ matrix.cc }}
224239

240+
- name: Build - Node
241+
working-directory: node-bindings
242+
run: |
243+
npm install --ignore-scripts
244+
npm run build-${{ matrix.platform }}-${{ matrix.architecture }}
245+
225246
- name: Code sign bin (Windows)
226247
if: matrix.os == 'windows-latest'
227248
run: |
@@ -267,32 +288,47 @@ jobs:
267288
"${msi_path}"
268289
269290
# Don't compress for Windows because winget can't yet unzip files
270-
- name: Compress artifact (Not Windows)
291+
- name: Compress cargo artifact (Not Windows)
271292
if: matrix.os != 'windows-latest'
272-
run: zip --junk-paths clarinet-${{ matrix.platform }} ./target/${{ matrix.target }}/release/clarinet
293+
run: tar -C target/${{ matrix.target }}/release -zcvf clarinet-${{ matrix.platform }}-${{ matrix.architecture }}.tar.gz clarinet
273294

274-
- name: Rename artifact (Windows)
295+
- name: Rename cargo artifact (Windows)
275296
if: matrix.os == 'windows-latest'
276-
run: mv target/wix/*.msi clarinet-${{ matrix.platform }}.msi
297+
shell: bash
298+
run: mv target/wix/*.msi clarinet-${{ matrix.platform }}-${{ matrix.architecture }}.msi
299+
300+
- name: Compress node artifact
301+
shell: bash
302+
run: tar -C node-bindings -zcvf clarinet-js-${{ matrix.platform }}-${{ matrix.architecture }}.tar.gz native/index.node
277303

278304
# Separate uploads to prevent paths from being preserved
279-
- name: Upload artifact (Not Windows)
305+
- name: Upload cargo artifacts (Not Windows)
280306
if: matrix.os != 'windows-latest'
281307
uses: actions/upload-artifact@v2
282308
with:
283-
name: clarinet-${{ matrix.platform }}
284-
path: clarinet-${{ matrix.platform }}.zip
309+
name: clarinet-${{ matrix.platform }}-${{ matrix.architecture }}
310+
path: clarinet-${{ matrix.platform }}-${{ matrix.architecture }}.tar.gz
285311

286-
- name: Upload artifact (Windows)
312+
- name: Upload cargo artifact (Windows)
287313
if: matrix.os == 'windows-latest'
288314
uses: actions/upload-artifact@v2
289315
with:
290-
name: clarinet-${{ matrix.platform }}
291-
path: clarinet-${{ matrix.platform }}.msi
316+
name: clarinet-${{ matrix.platform }}-${{ matrix.architecture }}
317+
path: clarinet-${{ matrix.platform }}-${{ matrix.architecture }}.msi
292318

293-
- name: Unit Tests
319+
- name: Upload node artifact
320+
uses: actions/upload-artifact@v2
321+
with:
322+
name: clarinet-js-${{ matrix.platform }}-${{ matrix.architecture }}
323+
path: clarinet-js-${{ matrix.platform }}-${{ matrix.architecture }}.tar.gz
324+
325+
- name: Unit Tests - Cargo
294326
run: cargo test --release --locked --target ${{ matrix.target }}
295327

328+
# - name: Unit Tests - Node
329+
# working-directory: node-bindings
330+
# run: npm run spec
331+
296332
- name: Functional Tests (Not Windows)
297333
if: matrix.os != 'windows-latest'
298334
run: |
@@ -312,15 +348,15 @@ jobs:
312348
if: startsWith(github.ref, 'refs/tags/v') && matrix.os != 'windows-latest'
313349
with:
314350
repo_token: ${{ secrets.GITHUB_TOKEN }}
315-
file: clarinet-${{ matrix.platform }}.zip
351+
file: clarinet-${{ matrix.platform }}-${{ matrix.architecture }}.zip
316352
tag: ${{ github.ref }}
317353

318354
- name: Upload Artifacts to GH release (Windows)
319355
uses: svenstaro/upload-release-action@v2
320356
if: startsWith(github.ref, 'refs/tags/v') && matrix.os == 'windows-latest'
321357
with:
322358
repo_token: ${{ secrets.GITHUB_TOKEN }}
323-
file: clarinet-${{ matrix.platform }}.msi
359+
file: clarinet-${{ matrix.platform }}-${{ matrix.architecture }}.msi
324360
tag: ${{ github.ref }}
325361

326362
# Cleans the `./target` dir after the build such that only dependencies are cached on CI

0 commit comments

Comments
 (0)