Skip to content

Commit

Permalink
Merge pull request #2 from vbudovski/feature/ci-tests
Browse files Browse the repository at this point in the history
feature: Run tests in CI
  • Loading branch information
vbudovski authored Jul 14, 2024
2 parents d31a925 + ae91ae6 commit 520918c
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Pull request

on:
pull_request:
types: [ opened, synchronize, reopened ]

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
test:
uses: ./.github/workflows/test.yml
secrets:
GIST_SECRET: ${{ secrets.GIST_SECRET }}
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
test:
uses: ./.github/workflows/test.yml
secrets:
GIST_SECRET: ${{ secrets.GIST_SECRET }}
54 changes: 54 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test

on:
workflow_call:
secrets:
GIST_SECRET:
required: true

jobs:
unit:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: "^1.45"

- name: Get pnpm store directory
id: deno-cache
shell: bash
run: |
echo "DENO_DIR=$(deno info | grep DENO_DIR | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' | cut -d ':' -f 2 | xargs)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup Deno cache
with:
path: ${{ steps.deno-cache.outputs.DENO_DIR }}
key: ${{ runner.os }}-deno-cache
restore-keys: |
${{ runner.os }}-deno-cache
- name: Run tests
id: tests
run: |
cd paseri-lib && deno test --coverage
echo "CODE_COVERAGE=$(deno coverage | grep "All files" | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' | cut -d '|' -f 2 | xargs)" >> $GITHUB_OUTPUT
echo "GIST_PATH=$(echo "${{ github.repository }}/${{ github.ref_name }}" | sed 's/\//_/g')-coverage.svg" >> $GITHUB_OUTPUT
- name: Create coverage badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 80548a1b87f9f00fe1ae426ca6a2a517
filename: ${{ steps.tests.outputs.GIST_PATH }}
label: coverage
message: ${{ steps.tests.outputs.CODE_COVERAGE }}%
valColorRange: ${{ steps.tests.outputs.CODE_COVERAGE }}
minColorRange: 50
maxColorRange: 90
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.env
.env.*

node_modules/
1 change: 1 addition & 0 deletions paseri-lib/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
coverage/
dist/

0 comments on commit 520918c

Please sign in to comment.