Skip to content

Commit

Permalink
ci(test): 增加 Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
twinh committed Oct 6, 2021
1 parent 87616ea commit 046ac83
Showing 1 changed file with 134 additions and 0 deletions.
134 changes: 134 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Build

on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '20 0 * * *'

jobs:
jest:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [ 10, 12, 14, 16 ]
steps:
- uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Replace package dependencies
run: npx replace-pkg-dep package.json

- name: Yarn install
run: yarn install

- name: Run
run: yarn miaoxing-jest

- name: Coveralls
if: startsWith(hashFiles('coverage/lcov.info'), '5df6e0e27613') == false
continue-on-error: true
env:
COVERALLS_FLAG_NAME: node-${{ matrix.node-version }}
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true

coveralls-finish:
needs: [ jest ]
runs-on: ubuntu-18.04
continue-on-error: true
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true

eslint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 16 ]

steps:
- uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Replace package dependencies
run: npx replace-pkg-dep package.json

- name: Yarn install
run: yarn install

- name: Run
run: yarn miaoxing-eslint

stylelint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 16 ]
steps:
- uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Replace package dependencies
run: npx replace-pkg-dep package.json

- name: Yarn install
run: yarn install

- name: Run
run: yarn miaoxing-stylelint

0 comments on commit 046ac83

Please sign in to comment.