-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: β¨ π Add GitHub Actions workflow for running unit tests
- Loading branch information
1 parent
7da05a5
commit de976ef
Showing
2 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# GitHub Actions | ||
# https://docs.github.com/en/actions/using-workflows | ||
name: Run Unit Tests | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
jobs: | ||
test: | ||
timeout-minutes: 30 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: .nvmrc | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v4 | ||
# give it a name for checking the cache hit-or-not | ||
id: cache-dependencies | ||
with: | ||
path: | | ||
node_modules | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Install Dependencies | ||
if: steps.cache-dependencies.outputs.cache-hit != 'true' | ||
run: npm ci | ||
|
||
- name: Run Tests | ||
run: npm run test:unit:coverage | ||
env: | ||
CI: true | ||
|
||
- name: Unit test report status | ||
if: always() | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const { job, conclusion } = context.payload; | ||
const status = conclusion === 'success' ? 'β ' : 'β'; | ||
const message = `Tests ${conclusion} ${status}`; | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: message | ||
}); | ||
- name: Upload coverage report | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: coverage-report | ||
path: reports/unit/coverage | ||
retention-days: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters