diff --git a/.github/workflows/cache-dependencies.yml b/.github/workflows/cache-dependencies.yml new file mode 100644 index 00000000..7aa96fc4 --- /dev/null +++ b/.github/workflows/cache-dependencies.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..7b309178 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/functions/jest.config.js b/functions/jest.config.js index 9ee81b0f..37ca1460 100644 --- a/functions/jest.config.js +++ b/functions/jest.config.js @@ -1,5 +1,5 @@ module.exports = { - roots: ["/src/", "/test/"], + roots: ["/src/"], transform: { "^.+\\.tsx?$": "ts-jest", }, diff --git a/functions/package.json b/functions/package.json index e41dd94f..aad6c612 100644 --- a/functions/package.json +++ b/functions/package.json @@ -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" },