Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat[ci]: run tests and report coverage for PR #33

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 9 additions & 25 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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