Skip to content

Commit

Permalink
ci(NODE-6185): add test and lint tasks to CI (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson authored Jun 11, 2024
1 parent bd3ce63 commit 39d898a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/docker/Dockerfile.glibc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ FROM $NODE_BUILD_IMAGE AS build
WORKDIR /mongodb-client-encryption
COPY . .

RUN node /mongodb-client-encryption/.github/scripts/libmongocrypt.mjs
RUN npm run install:libmongocrypt
RUN npm run test

FROM scratch

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [main]
workflow_dispatch: {}

name: build
name: Build and Test

jobs:
host_builds:
Expand All @@ -20,6 +20,10 @@ jobs:
run: node .github/scripts/libmongocrypt.mjs ${{ runner.os == 'Windows' && '--build' || '' }}
shell: bash

- name: Test ${{ matrix.os }}
shell: bash
run: npm run test

- id: upload
name: Upload prebuild
uses: actions/upload-artifact@v4
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

name: ${{ matrix.lint-target }}
strategy:
matrix:
lint-target: ["c++", "typescript"]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: "Build libmongocrypt"
shell: bash
run: |
npm run install:libmongocrypt
- if: matrix.lint-target == 'c++'
shell: bash
run: |
npm run check:clang-format
- if: matrix.lint-target == 'typescript'
shell: bash
run: |
npm run check:eslint
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"lib": "lib"
},
"scripts": {
"install:libmongocrypt": "node .github/scripts/libmongocrypt.mjs",
"install": "prebuild-install --runtime napi || node-gyp rebuild",
"clang-format": "clang-format --style=file:.clang-format --Werror -i addon/*",
"check:eslint": "eslint src test",
Expand Down
14 changes: 11 additions & 3 deletions test/release.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ const REQUIRED_FILES = [
describe(`Release ${packFile}`, function () {
this.timeout(10000);

beforeEach(function () {
if (process.arch !== 'x64') {
this.skip();
}
});

let tarFileList;
before(() => {
beforeEach(() => {
expect(fs.existsSync(packFile)).to.equal(false);
cp.execSync('npm pack', { stdio: 'ignore' });
tarFileList = [];
Expand All @@ -38,8 +44,10 @@ describe(`Release ${packFile}`, function () {
});
});

after(() => {
fs.unlinkSync(packFile);
afterEach(() => {
if (process.arch === 'x64') {
fs.unlinkSync(packFile);
}
});

for (const requiredFile of REQUIRED_FILES) {
Expand Down

0 comments on commit 39d898a

Please sign in to comment.