Skip to content

Commit

Permalink
Merge pull request #10 from jaydenchee97/feature
Browse files Browse the repository at this point in the history
Create run-tests.yml
  • Loading branch information
jaydenchee97 authored Mar 3, 2024
2 parents 36ee7ba + 85eeb46 commit c05cb20
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI

on:
push:
branches: ["develop"]
pull_request:
branches: ["develop"]

env:
minCoverage: ${{ vars.COVERAGE_VAR }}

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run test
run: npm run test:ci
- name: Collect code coverage
id: collect
run: |
echo "coverage<<EOF" >> $GITHUB_OUTPUT
cat coverage/coverage-summary.json >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Archive code coverage
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: coverage/
- name: Check %
id: check
run: |
echo "Min coverage is $minCoverage%"
echo "Current coverage is ${{ fromJSON(steps.collect.outputs.coverage).total.lines.pct }}%"
echo "pct=${{ fromJSON(steps.collect.outputs.coverage).total.lines.pct }}" >> $GITHUB_OUTPUT
- name: Exit 1
if: ${{ steps.check.outputs.pct < env.minCoverage }}
run: |
exit 1

0 comments on commit c05cb20

Please sign in to comment.