Skip to content

ci(NODE-6185): Add test and lint tasks to CI #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/docker/Dockerfile.glibc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ WORKDIR /mongodb-client-encryption
COPY . .

RUN node /mongodb-client-encryption/.github/scripts/libmongocrypt.mjs
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
40 changes: 40 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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: |
node .github/scripts/libmongocrypt.mjs
npm install
npm run prebuild

- 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
Loading