Skip to content

Commit 3e29d67

Browse files
committed
Build ESM -> CJS before running legacy Node.js tests and packaging tests
Because the source code is written in ESM syntax and we cannot use the `esm` package to make `require()` ESM compatible, since that package does not support legacy versions of Node.js. Also in our usage tests in CI, we need to mimck the npm packaging behaviour where building is involved.
1 parent 69bf4bd commit 3e29d67

3 files changed

Lines changed: 64 additions & 1 deletion

File tree

.github/workflows/usage.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,41 @@ name: Package usage
33
on: [push, pull_request]
44

55
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Setup Node.js
12+
uses: actions/setup-node@v1
13+
with:
14+
node-version: 14.x
15+
- name: npm install and build
16+
run: |
17+
npm install
18+
npm run build
19+
- name: Store build-output for later
20+
uses: actions/upload-artifact@v2
21+
with:
22+
name: build-output
23+
path: |
24+
mustache.js
25+
mustache.mjs
26+
627
package:
728
runs-on: ubuntu-latest
829

30+
needs: build
931
steps:
1032
- uses: actions/checkout@v2
1133
- name: Setup Node.js
1234
uses: actions/setup-node@v1
1335
with:
1436
node-version: 14.x
37+
- name: Get build-output from build step
38+
uses: actions/download-artifact@v2
39+
with:
40+
name: build-output
1541
- name: Create package tarball
1642
run: |
1743
export ARCHIVE_FILENAME=$(npm pack | tail -n 1)
@@ -71,12 +97,17 @@ jobs:
7197
browser-usage:
7298
runs-on: ubuntu-latest
7399

100+
needs: build
74101
steps:
75102
- uses: actions/checkout@v1
76103
- name: Setup Node.js
77104
uses: actions/setup-node@v1
78105
with:
79106
node-version: 12.x
107+
- name: Get build-output from build step
108+
uses: actions/download-artifact@v2
109+
with:
110+
name: build-output
80111
- name: Install and test
81112
run: |
82113
npm ci
@@ -85,10 +116,15 @@ jobs:
85116
deno-usage:
86117
runs-on: ubuntu-latest
87118

119+
needs: build
88120
steps:
89121
- uses: actions/checkout@v1
90122
- uses: denolib/setup-deno@master
91123
with:
92124
deno-version: 'v1.0.0'
125+
- name: Get build-output from build step
126+
uses: actions/download-artifact@v2
127+
with:
128+
name: build-output
93129
- run: deno --version
94130
- run: deno test --allow-net=deno.land test/module-systems/deno-test.ts

.github/workflows/verify.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,35 @@ jobs:
3535
npm install
3636
npm run test-unit
3737
38+
build:
39+
runs-on: ubuntu-latest
40+
41+
steps:
42+
- uses: actions/checkout@v2
43+
- name: Setup Node.js
44+
uses: actions/setup-node@v1
45+
with:
46+
node-version: 14.x
47+
- name: npm install and build
48+
run: |
49+
npm install
50+
npm run build
51+
- name: Store build-output for later
52+
uses: actions/upload-artifact@v2
53+
with:
54+
name: build-output
55+
path: |
56+
mustache.js
57+
mustache.mjs
58+
3859
tests-on-legacy:
3960
runs-on: ubuntu-latest
4061

4162
strategy:
4263
matrix:
4364
node-version: [0.10.x, 0.12.x, 4.x, 6.x, 8.x]
4465

66+
needs: build
4567
steps:
4668
- uses: actions/checkout@v2
4769
with:
@@ -50,6 +72,10 @@ jobs:
5072
uses: actions/setup-node@v1
5173
with:
5274
node-version: ${{ matrix.node-version }}
75+
- name: Get build-output from build step
76+
uses: actions/download-artifact@v2
77+
with:
78+
name: build-output
5379
- name: npm install and test
5480
run: |
5581
npm install mocha@3 chai@3

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"pre-test-browser": "node test/create-browser-suite.js",
3737
"test-browser": "npm run pre-test-browser && zuul -- test/context-test.js test/parse-test.js test/scanner-test.js test/render-test-browser.js",
3838
"test-browser-local": "npm run pre-test-browser && zuul --local 8080 -- test/context-test.js test/scanner-test.js test/parse-test.js test/render-test-browser.js",
39-
"postversion": "scripts/bump-version-in-source"
39+
"postversion": "scripts/bump-version-in-source",
40+
"prepublishOnly": "npm run build"
4041
},
4142
"devDependencies": {
4243
"chai": "^3.4.0",

0 commit comments

Comments
 (0)