Skip to content

Commit

Permalink
Simple CI test integration for Wasm
Browse files Browse the repository at this point in the history
Intentionally skipping coverage here, as Wasm doesn't cover everything.
  • Loading branch information
RReverser committed Jan 9, 2023
1 parent 65e504a commit b9e340c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
src/libvips/* linguist-vendored
build/** linguist-generated
build/Release/sharp-emscripten-wasm32.node.* linguist-generated
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
CI:
permissions:
contents: write # for npx prebuild to make release
name: ${{ matrix.container || matrix.os }} - Node.js ${{ matrix.nodejs_version }} ${{ matrix.nodejs_arch }} ${{ matrix.prebuild && '- prebuild' }}
name: ${{ matrix.container || matrix.os }} - Node.js ${{ matrix.nodejs_version }} ${{ matrix.addon_arch || matrix.nodejs_arch }} ${{ matrix.prebuild && '- prebuild' }}
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
Expand All @@ -31,6 +31,9 @@ jobs:
container: node:16-alpine3.12
- os: ubuntu-22.04
container: node:18-alpine3.14
- os: ubuntu-22.04
container: node:18-alpine3.14
addon_arch: wasm32
- os: macos-11
nodejs_version: 14
prebuild: true
Expand Down Expand Up @@ -95,9 +98,17 @@ jobs:
if: matrix.container
run: chown root.root .
- name: Install
if: matrix.addon_arch != 'wasm32'
run: npm install --build-from-source --unsafe-perm
- name: Install (WebAssembly)
if: matrix.addon_arch == 'wasm32'
run: npm install --ignore-scripts
- name: Test
if: matrix.addon_arch != 'wasm32'
run: npm test
- name: Test (WebAssembly)
if: matrix.addon_arch == 'wasm32'
run: npx --arch=wasm32 mocha
- name: Prebuild
if: matrix.prebuild && startsWith(github.ref, 'refs/tags/')
env:
Expand Down
18 changes: 7 additions & 11 deletions test/unit/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,19 @@ describe('Platform-detection', function () {
}
});

// Don't let outer npm_config_* variables leak into a platform test.
beforeEach(() => {
function cleanupEnv () {
for (const key of npmConfigKeys()) {
delete process.env[key];
}
});
}

// Don't let outer npm_config_* variables leak into a platform test.
beforeEach(cleanupEnv);

// Restore the original config for other test suites.
after(() => {
for (const key of npmConfigKeys()) {
const value = npmEnv[key];
if (value === undefined) {
delete process.env[key];
} else {
process.env[key] = value;
}
}
cleanupEnv();
Object.assign(process.env, npmEnv);
});

it('Can override arch with npm_config_arch', function () {
Expand Down

0 comments on commit b9e340c

Please sign in to comment.