Skip to content

Commit

Permalink
workflow: add github actions for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
PPpro committed Sep 9, 2023
1 parent 0beceb0 commit efea53c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 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 }}'s 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
13 changes: 13 additions & 0 deletions .github/workflows/scripts/api-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const fs = require('fs');
const ps = require('path');
const chalk = require('chalk');

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(chalk.red(`please run 'npm run api' to update public.d.ts, and commit this file.`));
process.exit(1);
}
15 changes: 15 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: test
run-name: ${{ github.actor }}'s test
on: [pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.17.0'

- run: npm ci

- run: npm test

0 comments on commit efea53c

Please sign in to comment.