Skip to content

Commit 12cd606

Browse files
feat: cover JS example under CI (#272)
* chore(lang/js): make jco tutorial easier to run Signed-off-by: Victor Adossi <vadossi@cosmonic.com> * feat(ci): add js lang to CI Signed-off-by: Victor Adossi <vadossi@cosmonic.com> * chore: add package-lock.json to generated Signed-off-by: Victor Adossi <vadossi@cosmonic.com> --------- Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
1 parent 52040b7 commit 12cd606

File tree

8 files changed

+2121
-71
lines changed

8 files changed

+2121
-71
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
# Genrated code from cargo-component
88
component-model/examples/tutorial/*/src/bindings.rs linguist-generated
99

10+
# Generated code from JS tutorial
11+
component-model/examples/tutorial/jco/package-lock.json linguist-generated
12+
1013
Cargo-component.lock linguist-language=toml
1114

.github/workflows/js.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: javascript
2+
3+
on:
4+
merge_group:
5+
push:
6+
branches:
7+
- main
8+
9+
pull_request:
10+
branches:
11+
- main
12+
13+
defaults:
14+
run:
15+
shell: bash
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
node-version:
27+
- 18.x
28+
- 20.x
29+
- latest
30+
projects:
31+
- folder: component-model/examples/tutorial/jco
32+
script-target: all
33+
steps:
34+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35+
36+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
37+
with:
38+
node-version: ${{ matrix.node-version }}
39+
40+
- name: Cache npm install
41+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
42+
with:
43+
key: node-modules-${{ matrix.node-version }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('${{ matrix.projects.folder }}/package-lock.json') }}
44+
path: |
45+
${{ matrix.projects.folder }}
46+
47+
- name: Install NodeJS dependencies
48+
working-directory: ${{ matrix.projects.folder }}
49+
run: |
50+
npm install
51+
52+
- name: Run NodeJS script target
53+
working-directory: ${{ matrix.projects.folder }}
54+
run: |
55+
npm run ${{ matrix.projects.script-target }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
# Build artifacts from examples
77
**/jco/bindings
88
**/examples/**/*.wasm
9+
/component-model/examples/tutorial/jco/node_modules/

component-model/examples/tutorial/calculator/src/bindings.rs

Lines changed: 56 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
28.8 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// See the README for details on *generation* of the required import
2-
import { calculate } from "./bindings/composed.js";
2+
import { calculate } from "./bindings/calculator.composed.js";
33

44
console.log("Answer (to life) = " + calculate.evalExpression("add", 21, 21));

0 commit comments

Comments
 (0)