.github/workflows/unit-tests.yml
---
name: Unit Tests
on: # yamllint disable-line rule:truthy
pull_request:
paths:
- dist/**
- src/**
- jest.config.json
push:
branches:
- main
defaults:
run:
shell: sh
jobs:
unit-tests:
name: Unit Tests
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
- name: Cache yarn dependencies
id: yarn-cache
uses: actions/cache@v4
with:
path: |
.yarn/cache
node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/.yarnrc.yml') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Compile
if: ${{ steps.yarn-cache.outputs.cache-hit != 'true' }}
run: yarn install
- name: Unit tests
if: github.ref != 'refs/heads/main'
env:
DEEPL_API_KEY: ${{ secrets.DEEPL_API_KEY }}
MYMEMORY_API_KEY: ${{ secrets.MYMEMORY_API_KEY }}
run: yarn test
- name: Unit tests with coverage
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: paambaati/codeclimate-action@v9.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
DEEPL_API_KEY: ${{ secrets.DEEPL_API_KEY }}
MYMEMORY_API_KEY: ${{ secrets.MYMEMORY_API_KEY }}
with:
coverageCommand: yarn test
debug: true