Skip to content

Commit

Permalink
ci: add workflows for linting and testing (#50)
Browse files Browse the repository at this point in the history
* Add npm scripts

* Add workflows

* Update working-directory config

* Fix Jest config file

* Swap matrix-based config for env-based config

* Allow CI to pass with no tests

* Revert "Swap matrix-based config for env-based config"

This reverts commit b0a0e09.
  • Loading branch information
Ezard authored Jun 4, 2022
1 parent ee702d0 commit 9d30672
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/cache-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Cache Dependencies

on:
push:
branches:
- master

jobs:
cache-dependencies:
strategy:
matrix:
os:
- ubuntu-20.04
node-version:
- 16
runs-on: ${{ matrix.os }}
name: Cache Dependencies
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js for use with actions
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Setup dependency cache
uses: actions/cache@v2
id: cache
with:
path: node_modules
key: ${{ matrix.os }}-node-${{ matrix.node-version }}-${{ hashFiles('functions/package-lock.json') }}
- name: Install dependencies
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: npm ci
working-directory: functions
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
pull_request:
branches:
- master

jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-20.04
node-version:
- 16
name: CI
steps:
- name: Configure Git
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js for use with actions
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Setup dependency cache
id: cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ matrix.os }}-node-${{ matrix.node-version }}-${{ hashFiles('functions/package-lock.json') }}
- name: Install dependencies
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: npm ci
working-directory: functions
- name: Lint code
run: npm run lint:code
working-directory: functions
- name: Lint styling
run: npm run lint:style
working-directory: functions
- name: Run unit tests
run: npm run test:unit:coverage -- --passWithNoTests
working-directory: functions
2 changes: 1 addition & 1 deletion functions/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
roots: ["<rootDir>/src/", "<rootDir>/test/"],
roots: ["<rootDir>/src/"],
transform: {
"^.+\\.tsx?$": "ts-jest",
},
Expand Down
4 changes: 3 additions & 1 deletion functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"lint": "npm run lint:code && npm run lint:style",
"lint:code": "eslint src",
"lint:style": "prettier --check src",
"test": "jest",
"test": "npm run test:unit",
"test:unit": "jest",
"test:unit:coverage": "jest --coverage",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
Expand Down

0 comments on commit 9d30672

Please sign in to comment.