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 81b9d60 commit 97365a8
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 25 deletions.
34 changes: 9 additions & 25 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,29 @@ name: Deploy
on:
push:
branches:
- ci-test
- master
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'

jobs:
deploy:
name: deploy
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
- uses: actions/checkout@v4

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

- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
- name: "Install Node"
uses: actions/setup-node@v4
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
node-version: "20"
cache: "yarn"

- name: setup
run: yarn
- name: "Setup"
run: yarn install

- name: test
- name: "Test"
run: yarn test

- name: deploy
- name: "Deploy"
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
run: |
yarn deploy
61 changes: 61 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: PR tests
on:
pull_request:

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

permissions:
contents: read

steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}

- name: "Install Node"
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- 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:
- uses: actions/checkout@v4

- name: "Download HEAD coverage artifacts"
uses: actions/download-artifact@v4
with:
name: coverage-${{ github.head_ref }}
path: coverage

- name: "Download master coverage artifacts"
uses: actions/download-artifact@v4
with:
name: coverage-master
path: coverage-master

- name: "Report Coverage"
uses: davelosert/vitest-coverage-report-action@v2
with:
json-summary-compare-path: coverage-master/coverage-summary.json

0 comments on commit 97365a8

Please sign in to comment.