Skip to content

Commit

Permalink
feat[ci]: run tests and report coverage for PR
Browse files Browse the repository at this point in the history
  • Loading branch information
SharzyL committed Apr 13, 2024
1 parent 4415c63 commit 43d5e88
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 8 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ on:
branches:
- ci-test
- master
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'

jobs:
deploy:
Expand Down Expand Up @@ -43,4 +37,3 @@ jobs:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
run: |
yarn deploy
51 changes: 51 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: PR tests
on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
branch:
- ${{ github.head_ref }}
- "main"

permissions:
contents: read

steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
- name: "Install Node"
uses: actions/setup-node@v4
with:
node-version: "20"
- name: "Install Deps"
run: yarn install
- name: "Test"
run: yarn coverage
- name: "Upload Coverage"
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.branch }}
path: coverage

report-coverage:
needs: test
runs-on: ubuntu-latest
steps:
- name: "Download Coverage Artifacts"
uses: actions/download-artifact@v4
with:
name: coverage-${{ github.head_ref }}
path: coverage
- uses: actions/download-artifact@v4
with:
name: coverage-main
path: coverage-main
- name: "Report Coverage"
uses: davelosert/vitest-coverage-report-action@v2
with:
json-summary-compare-path: coverage-main/coverage-summary.json
2 changes: 1 addition & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const cfg = defineWorkersConfig({
test: {
coverage: {
provider: "istanbul", // v8 is not supported due for cf workers
reporter: ["text", "json", "html"],
reporter: ["text", "json", "html", "json-summary"],
},
poolOptions: {
workers: {
Expand Down

0 comments on commit 43d5e88

Please sign in to comment.