Skip to content

Commit

Permalink
build: refactor GitHub Action jobs (#1875)
Browse files Browse the repository at this point in the history
* build(ci): split up fast and slow tests into separate jobs
* build(ci): replace glob with globby in test-globber.ts to split out integration tests better
* build(ci): parallelize fast tests
  • Loading branch information
malept authored Aug 1, 2020
1 parent 83be715 commit 4afa3dc
Show file tree
Hide file tree
Showing 5 changed files with 284 additions and 143 deletions.
69 changes: 55 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,61 @@ jobs:
env:
DEPENDABOLT_SSH_DEPLOY_KEY: ${{ secrets.DEPENDABOLT_SSH_DEPLOY_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test:
fast-tests:
runs-on: ${{ matrix.os }}
needs: dependabolt
strategy:
matrix:
os: [windows-latest, macOS-latest, ubuntu-latest]
node-installer: [npm, yarn]
steps:
- name: Fix git checkout line endings
run: git config --global core.autocrlf input
- uses: actions/checkout@v2
- name: Use Node.js 10.x
uses: actions/[email protected]
with:
node-version: 10.x
- name: Determine Yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache Yarn
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install bolt
shell: bash
run: |
case "$(uname -s)" in
Windows*|CYGWIN*|MINGW*|MSYS*) BOLT_VERSION=0.21.2 ;;
*) BOLT_VERSION=latest ;;
esac
npm install -g bolt@$BOLT_VERSION
- name: Install
run: bolt
- name: Lint
run: bolt lint
- name: Build
run: bolt build
- name: Run tests
run: bolt coverage:fast
- name: Upload code coverage to Codecov
uses: codecov/[email protected]
with:
file: ./coverage.lcov
env_vars: CI_OS,TEST_TYPE
env:
CI_OS: ${{ matrix.os }}
TEST_TYPE: fast

slow-tests:
runs-on: ${{ matrix.os }}
needs: dependabolt
strategy:
matrix:
os: [windows-latest, macOS-latest, ubuntu-latest]
steps:
- name: Fix git checkout line endings
run: git config --global core.autocrlf input
Expand Down Expand Up @@ -69,10 +116,6 @@ jobs:
npm install -g bolt@$BOLT_VERSION
- name: Install
run: bolt
- name: Lint
run: bolt lint
- name: Build
run: bolt build
- name: Test on Windows
if: matrix.os == 'windows-latest'
run: |
Expand All @@ -83,26 +126,24 @@ jobs:
{
Write-Host "Unable to find light.exe in your PATH"
}
bolt coverage
env:
NODE_INSTALLER: ${{ matrix.node-installer }}
bolt coverage:slow
- name: Test on macOS/Linux
if: matrix.os != 'windows-latest'
run: bolt coverage
run: bolt coverage:slow
env:
NODE_INSTALLER: ${{ matrix.node-installer }}
DEBUG: electron-installer-snap:snapcraft
- name: Upload code coverage to Codecov
uses: codecov/[email protected]
with:
file: ./coverage.lcov
env_vars: CI_OS,NODE_INSTALLER
env_vars: CI_OS,TEST_TYPE
env:
CI_OS: ${{ matrix.os }}
NODE_INSTALLER: ${{ matrix.node-installer }}
TEST_TYPE: slow

# docs:
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
# needs: test
# needs: [fast-tests, slow-tests]
# runs-on: [ubuntu-latest]
# steps:
# - uses: actions/checkout@v1
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
"build:quick": "bolt ws exec -- node_modules/.bin/babel src -d dist --quiet --extensions \".ts\" --config-file ../../../.babelrc",
"postbuild": "ts-node tools/test-dist",
"commit": "git-cz",
"coverage": "cross-env TS_NODE_FILES=true nyc mocha './tools/test-globber.ts' && nyc report --reporter=text-lcov > coverage.lcov",
"coverage:fast": "cross-env INTEGRATION_TESTS=0 TS_NODE_FILES=true nyc mocha --parallel './tools/test-globber.ts' && nyc report --reporter=text-lcov > coverage.lcov",
"coverage:slow": "cross-env TS_NODE_FILES=true nyc mocha './tools/test-globber.ts' --integration && nyc report --reporter=text-lcov > coverage.lcov",
"docs": "bolt docs:generate && bolt docs:position",
"docs:generate": "bolt ws exec -- node_modules/.bin/typedoc --out doc --excludeExternals --ignoreCompilerErrors --mode file --excludePrivate --excludeProtected --hideGenerator",
"docs:position": "ts-node tools/position-docs.ts",
"docs:deploy": "ts-node tools/sync-readmes.ts && bolt docs && ts-node tools/copy-now.ts && cd docs && now && now alias",
"docs:deploy:ci": "ts-node tools/sync-readmes.ts && bolt docs && ts-node tools/copy-now.ts && cd docs && now --token $NOW_TOKEN && now alias --token $NOW_TOKEN",
"lint": "eslint --ext .ts .",
"test": "cross-env TS_NODE_FILES=true yarn run mocha './tools/test-globber.ts'",
"test:fast": "cross-env TEST_FAST_ONLY=1 TS_NODE_FILES=true yarn run mocha --parallel './tools/test-globber.ts'",
"postinstall": "rimraf node_modules/.bin/*.ps1 && ts-node tools/link-ts.ts"
},
"dependencies": {
Expand Down Expand Up @@ -129,6 +131,7 @@
"eslint-plugin-mocha": "^7.0.1",
"fetch-mock": "^9.10.4",
"generate-changelog": "^1.8.0",
"globby": "^11.0.1",
"husky": "^4.2.5",
"lint-staged": "^10.2.11",
"listr": "^0.14.1",
Expand Down
Loading

0 comments on commit 4afa3dc

Please sign in to comment.