Skip to content

ci: set up GitHub Actions #36

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 9 commits into from
Sep 3, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
61 changes: 61 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Node CI

on:
workflow_dispatch:
push:
branches:
- master
- develop
pull_request:
branches:
- '**'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
prepare-npm-cache-ubuntu:
uses: ./.github/workflows/prepare-cache.yml
with:
os: ubuntu-latest
prepare-npm-cache-macos:
uses: ./.github/workflows/prepare-cache.yml
with:
os: macos-latest
prepare-npm-cache-windows:
uses: ./.github/workflows/prepare-cache.yml
with:
os: windows-latest

lint:
name: Lint
runs-on: ubuntu-latest
needs: prepare-npm-cache-ubuntu

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm
- name: install
run: npm ci
- name: run eslint
run: npm run lint

test-ubuntu:
uses: ./.github/workflows/test.yml
needs: prepare-npm-cache-ubuntu
with:
os: ubuntu-latest
test-macos:
uses: ./.github/workflows/test.yml
needs: prepare-npm-cache-macos
with:
os: macos-latest
test-windows:
uses: ./.github/workflows/test.yml
needs: prepare-npm-cache-windows
with:
os: windows-latest
24 changes: 24 additions & 0 deletions .github/workflows/prepare-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Prepare CI cache

on:
workflow_call:
inputs:
os:
required: true
type: string

jobs:
prepare-npm-cache:
name: Prepare npm cache for ${{ inputs.os }}
runs-on: ${{ inputs.os }}

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm

- name: Validate cache
run: npm ci --omit optional
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: TEst

on:
workflow_call:
inputs:
os:
required: true
type: string

jobs:
test:
strategy:
fail-fast: false
matrix:
node-version: [14.x, 16.x]
name: Node v${{ matrix.node-version }} on ${{ inputs.os }}
runs-on: ${{ inputs.os }}

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: install
run: npm ci
- name: run tests
run: npm run jest-ci
16 changes: 12 additions & 4 deletions CHANGELOG_V4+.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- GitHub workflows for CI.
- Jest config for GitHub Actions - `jest.config.ci.mjs`.
- NPM scripts:
- `lint` to run ESLint from CLI.
- `jest` to replace the original `test` script with the following changes:
- Removed `jest --clearCache` at the beginning as the updated Jest & ts-jest
settings execute the dynamic import lines with no issue.
- Disabled Node experimental warning message by setting `NODE_NO_WARNINGS=1`.
- `jest-ci` to run Jest with CI config - `jest.config.ci.mjs`.

### Changed
- File extension of Jest & Webpack config files to `mjs`.
- NPM `test` script:
- Removed `jest --clearCache` at the beginning as the updated Jest & ts-jest
settings execute the dynamic import lines with no issue.
- Disabled Node experimental warning message by setting `NODE_NO_WARNINGS=1`.
- NPM `test` script to run scripts `lint` then `jest`.
- Rolled back the value of `moduleResolution` in `tsconfig` to `Node` (means
`.js` file extension on relative imports is now __OPTIONAL__).
- Enhanced function `pathsToESModuleNameMapper` in `jest.config.js` to return a
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ To package your Electron app, run `npm run prod` to get your code compiled in
- `.gitignore` - Git ignore file
- `CHANGELOG_PRE_V4.md` - Changelog of this boilerplate prior to `v4.0.0`
- `CHANGELOG_V4+.md` - Changelog of this boilerplate from `v4.0.0` onwards
- `jest.config.js` - [Jest] config file
- `jest.config.ci.mjs` - [Jest] config file for GitHub Actions
- `jest.config.mjs` - [Jest] config file
- `LICENSE` - MIT license
- `package-lock.json`
- `package.json`
Expand Down
8 changes: 8 additions & 0 deletions jest.config.ci.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import baseConfig from './jest.config.mjs';

/** @type {import('jest').Config} */
export default {
...baseConfig,
coverageReporters: ['json'],
reporters: ['default', 'github-actions'],
};
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
"start": "electron ./dist/main.bundle.js",
"dev": "rimraf dist && cross-env NODE_ENV=development webpack --watch --progress --color",
"prod": "rimraf dist && cross-env NODE_ENV=production webpack --progress --color",
"test": "cross-env NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest",
"watch-test": "npm run test -- --watchAll",
"jest": "cross-env NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest",
"jest-ci": "npm run jest -- --config jest.config.ci.mjs",
"watch-jest": "npm run jest -- --watchAll",
"lint": "eslint . --cache --ext js,jsx,cjs,mjs,ts,tsx",
"test": "npm run lint && npm run jest",
"next-rc": "npm --no-git-tag-version version prerelease --preid=rc",
"next-patch": "npm --no-git-tag-version version patch",
"next-minor": "npm --no-git-tag-version version minor",
Expand Down