Skip to content

Commit

Permalink
workflow: add github actions for CI (#43)
Browse files Browse the repository at this point in the history
* workflow: add github actions for CI

* format run-name

* remove chalk

* add strategy to run on multiple OS

* fix

* fix runs-on

* fail-fast

* config global test timeout
  • Loading branch information
PPpro authored Sep 9, 2023
1 parent 0beceb0 commit 142574b
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 7 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/api-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: api-check
run-name: ${{ github.actor }} - api check
on: [pull_request]
jobs:
api-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.17.0'

- run: npm ci

- name: Copy old public.d.ts
run: mv ./.api/public.d.ts ./.api/public_old.d.ts

- run: npm run api

- name: Compare api
run: node ./.github/workflows/scripts/api-check.js
12 changes: 12 additions & 0 deletions .github/workflows/scripts/api-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const fs = require('fs');
const ps = require('path');

const oldVer = ps.join(__dirname, '../../../.api/public_old.d.ts');
const newVer = ps.join(__dirname, '../../../.api/public.d.ts');
const oldContent = fs.readFileSync(oldVer, 'utf8');
const newContent = fs.readFileSync(newVer, 'utf8');

if (oldContent !== newContent) {
console.error(`please run 'npm run api' to update public.d.ts, and commit this file.`);
process.exit(1);
}
19 changes: 19 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: test
run-name: ${{ github.actor }} - test
on: [pull_request]
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.17.0'

- run: npm ci

- run: npm test
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ module.exports = {
// The directory where Jest should store its cached dependency information
// cacheDirectory: "C:\\Users\\pp\\AppData\\Local\\Temp\\jest",

// global test timeout
testTimeout: 50000,

// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,

Expand Down
2 changes: 0 additions & 2 deletions test/build-engine/engine-js.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import * as fs from 'fs-extra';
import del from 'del';
import { getOutputContent, getOutputDirStructure } from '../utils';

jest.setTimeout(10000);

describe('engine-js', () => {
test('build WASM module on platform supporting WASM', async () => {
const out = ps.join(__dirname, './lib-js');
Expand Down
1 change: 0 additions & 1 deletion test/build-engine/engine-ts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { formatPath, ps } from '@ccbuild/utils';
import { getOutputContent, getOutputDirStructure } from '../utils';
import { buildEngine } from '@ccbuild/build-engine';

jest.setTimeout(10000);
test('engine-ts', async () => {
const engineBuilder = new ccbuild.EngineBuilder();
const root = formatPath(ps.join(__dirname, '../test-engine-source'));
Expand Down
2 changes: 0 additions & 2 deletions test/build-engine/module-query-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { getOutputContent, getOutputDirStructure } from '../utils';
import del from 'del';
import fs from 'fs-extra';

jest.setTimeout(10000);

describe('module query plugin', () => {
const engineRoot = ps.join(__dirname, '../test-engine-source');

Expand Down
2 changes: 0 additions & 2 deletions test/dts-bundler/dts-bundler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { ps } from '@ccbuild/utils';
import del from 'del';
import { getOutputContent, getOutputDirStructure } from '../utils';

jest.setTimeout(10000);

test('bundle dts', async () => {
const entry = ps.join(__dirname, '../test-engine-source');
const out = ps.join(__dirname, './lib-dts');
Expand Down

0 comments on commit 142574b

Please sign in to comment.