Skip to content

Commit 653f4cd

Browse files
authored
ci: set up GitHub Actions (#36)
2 parents 5122732 + 07c09d6 commit 653f4cd

File tree

7 files changed

+141
-7
lines changed

7 files changed

+141
-7
lines changed

.github/workflows/nodejs.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Node CI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
- develop
9+
pull_request:
10+
branches:
11+
- '**'
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
prepare-npm-cache-ubuntu:
19+
uses: ./.github/workflows/prepare-cache.yml
20+
with:
21+
os: ubuntu-latest
22+
prepare-npm-cache-macos:
23+
uses: ./.github/workflows/prepare-cache.yml
24+
with:
25+
os: macos-latest
26+
prepare-npm-cache-windows:
27+
uses: ./.github/workflows/prepare-cache.yml
28+
with:
29+
os: windows-latest
30+
31+
lint:
32+
name: Lint
33+
runs-on: ubuntu-latest
34+
needs: prepare-npm-cache-ubuntu
35+
36+
steps:
37+
- uses: actions/checkout@v3
38+
- uses: actions/setup-node@v3
39+
with:
40+
node-version: lts/*
41+
cache: npm
42+
- name: install
43+
run: npm ci
44+
- name: run eslint
45+
run: npm run lint
46+
47+
test-ubuntu:
48+
uses: ./.github/workflows/test.yml
49+
needs: prepare-npm-cache-ubuntu
50+
with:
51+
os: ubuntu-latest
52+
test-macos:
53+
uses: ./.github/workflows/test.yml
54+
needs: prepare-npm-cache-macos
55+
with:
56+
os: macos-latest
57+
test-windows:
58+
uses: ./.github/workflows/test.yml
59+
needs: prepare-npm-cache-windows
60+
with:
61+
os: windows-latest

.github/workflows/prepare-cache.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Prepare CI cache
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
prepare-npm-cache:
12+
name: Prepare npm cache for ${{ inputs.os }}
13+
runs-on: ${{ inputs.os }}
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- uses: actions/setup-node@v3
19+
with:
20+
node-version: lts/*
21+
cache: npm
22+
23+
- name: Validate cache
24+
run: npm ci --omit optional

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: TEst
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
test:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
node-version: [14.x, 16.x]
16+
name: Node v${{ matrix.node-version }} on ${{ inputs.os }}
17+
runs-on: ${{ inputs.os }}
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: npm
26+
- name: install
27+
run: npm ci
28+
- name: run tests
29+
run: npm run jest-ci

CHANGELOG_V4+.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- GitHub workflows for CI.
10+
- Jest config for GitHub Actions - `jest.config.ci.mjs`.
11+
- NPM scripts:
12+
- `lint` to run ESLint from CLI.
13+
- `jest` to replace the original `test` script with the following changes:
14+
- Removed `jest --clearCache` at the beginning as the updated Jest & ts-jest
15+
settings execute the dynamic import lines with no issue.
16+
- Disabled Node experimental warning message by setting `NODE_NO_WARNINGS=1`.
17+
- `jest-ci` to run Jest with CI config - `jest.config.ci.mjs`.
18+
819
### Changed
920
- File extension of Jest & Webpack config files to `mjs`.
10-
- NPM `test` script:
11-
- Removed `jest --clearCache` at the beginning as the updated Jest & ts-jest
12-
settings execute the dynamic import lines with no issue.
13-
- Disabled Node experimental warning message by setting `NODE_NO_WARNINGS=1`.
21+
- NPM `test` script to run scripts `lint` then `jest`.
1422
- Rolled back the value of `moduleResolution` in `tsconfig` to `Node` (means
1523
`.js` file extension on relative imports is now __OPTIONAL__).
1624
- Enhanced function `pathsToESModuleNameMapper` in `jest.config.js` to return a

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ To package your Electron app, run `npm run prod` to get your code compiled in
275275
- `.gitignore` - Git ignore file
276276
- `CHANGELOG_PRE_V4.md` - Changelog of this boilerplate prior to `v4.0.0`
277277
- `CHANGELOG_V4+.md` - Changelog of this boilerplate from `v4.0.0` onwards
278-
- `jest.config.js` - [Jest] config file
278+
- `jest.config.ci.mjs` - [Jest] config file for GitHub Actions
279+
- `jest.config.mjs` - [Jest] config file
279280
- `LICENSE` - MIT license
280281
- `package-lock.json`
281282
- `package.json`

jest.config.ci.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import baseConfig from './jest.config.mjs';
2+
3+
/** @type {import('jest').Config} */
4+
export default {
5+
...baseConfig,
6+
coverageReporters: ['json'],
7+
reporters: ['default', 'github-actions'],
8+
};

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
"start": "electron ./dist/main.bundle.js",
88
"dev": "rimraf dist && cross-env NODE_ENV=development webpack --watch --progress --color",
99
"prod": "rimraf dist && cross-env NODE_ENV=production webpack --progress --color",
10-
"test": "cross-env NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest",
11-
"watch-test": "npm run test -- --watchAll",
10+
"jest": "cross-env NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest",
11+
"jest-ci": "npm run jest -- --config jest.config.ci.mjs",
12+
"watch-jest": "npm run jest -- --watchAll",
13+
"lint": "eslint . --cache --ext js,jsx,cjs,mjs,ts,tsx",
14+
"test": "npm run lint && npm run jest",
1215
"next-rc": "npm --no-git-tag-version version prerelease --preid=rc",
1316
"next-patch": "npm --no-git-tag-version version patch",
1417
"next-minor": "npm --no-git-tag-version version minor",

0 commit comments

Comments
 (0)