Skip to content

CI

CI #873

Workflow file for this run

name: CI
on:
push:
pull_request:
schedule:
- cron: '0 3 * * *' # daily, at 3am
jobs:
lint:
name: Lint
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14.x
- run: yarn
- run: yarn lint
- run: yarn tsd
test:
name: Test - ${{ matrix.os }}/node@${{ matrix.node-version }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-18.04 ]
node-version: [ 14.x ]
include:
# different platforms
- { os: ubuntu-18.04, node-version: 14.x }
- { os: windows-latest, node-version: 14.x }
- { os: macos-latest, node-version: 14.x }
# different Node.js
- { os: ubuntu-18.04, node-version: 10.x }
- { os: ubuntu-18.04, node-version: 12.x }
- { os: ubuntu-18.04, node-version: 14.x }
- { os: ubuntu-18.04, node-version: 16.x }
runs-on: ${{ matrix.os }}
env:
coverage-filename: ./coverage-final.${{ matrix.os }}_${{ matrix.node-version }}.json
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn --ignore-engines
- run: yarn test:coverage
- name: Unify different platfrom paths in coverage file
if: ${{ always() }}
shell: bash
run: |
node -e "
const cwdForReplace = process.cwd().replace(/\\\\/g, '\\\\\\\\');
const file = fs.readFileSync('./coverage/coverage-final.json', {encoding: 'utf8'});
const replaceBase = file.split(cwdForReplace).join('.cwd').replace(/\\\\\\\\/g, '/');
fs.writeFileSync(process.env['coverage-filename'], replaceBase);
"
- name: Save current coverage to artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: coverages
path: ${{ env.coverage-filename }}
retention-days: 1
coverage:
name: Coverage
needs: test
if: ${{ always() }}
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- name: Download all coverage files from previous job
uses: actions/download-artifact@v2
with:
name: coverages
path: ./coverages
- run: ls -laR ./coverages
- name: Normalize paths to absolute form
run: replace '.cwd' '${{ github.workspace }}' -- *
working-directory: ./coverages
- run: npx nyc merge ./coverages ./coverage/coverage-final.json
- run: >-
npx nyc report
--check-coverage true
--statements 100
--branches 98.2
--functions 100
--lines 100
-t ./coverage
--report-dir ./coverage
--reporter=html --reporter=lcov
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: coverages
path: ./**/coverage/
- uses: coverallsapp/[email protected]
if: ${{ always() }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}