diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..e61cce6 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1d892ce --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3b37315 --- /dev/null +++ b/.github/workflows/test.yml @@ -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/dynamic-badges-action@v1.7.0 + 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 diff --git a/.gitignore b/.gitignore index c2658d7..9ea408c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ +.env +.env.* + node_modules/ diff --git a/paseri-lib/.gitignore b/paseri-lib/.gitignore index 849ddff..d64c4ca 100644 --- a/paseri-lib/.gitignore +++ b/paseri-lib/.gitignore @@ -1 +1,2 @@ +coverage/ dist/