Merge pull request #55 from bensaufley/dependabot/npm_and_yarn/multi-… #100
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
name: CI | |
on: | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: 'Git ref to checkout' | |
required: false | |
type: string | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && github.inputs.ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
env: | |
APP_ENV: test | |
NODE_ENV: test | |
ROOT_DIR: ${{ github.workspace }} | |
CI: true | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.ref || github.ref }} | |
- name: Get Node Version | |
id: node-version | |
run: echo ::set-output name=node-version::$(cat .node-version) | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ steps.node-version.outputs.node-version }} | |
- name: Install dependencies | |
run: npm install | |
- name: Setup Code Climate test-reporter | |
run: | | |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | |
chmod +x ./cc-test-reporter | |
- name: Run Tests | |
env: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
JEST_JUNIT_OUTPUT_DIR: ./reports/junit/ | |
run: | | |
./cc-test-reporter before-build | |
npx vitest --coverage --reporter=default --reporter=junit --outputFile.junit=./reports/junit/junit.xml | |
./cc-test-reporter after-build --coverage-input-type lcov --exit-code $? | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
env: | |
APP_ENV: test | |
NODE_ENV: test | |
ROOT_DIR: ${{ github.workspace }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.ref || github.ref }} | |
- name: Get Node Version | |
id: node-version | |
run: echo ::set-output name=node-version::$(cat .node-version) | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ steps.node-version.outputs.node-version }} | |
- name: Install dependencies | |
run: npm install | |
- name: Lint | |
run: npm run check | |
lint-docker: | |
name: Lint Dockerfiles | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.ref || github.ref }} | |
- name: Make reports dir | |
run: mkdir -p ${{ github.workspace }}/reports | |
- uses: hadolint/[email protected] | |
with: | |
dockerfile: Dockerfile.dev | |
format: sarif | |
output-file: ${{ github.workspace }}/reports/Dev.sarif | |
- uses: hadolint/[email protected] | |
with: | |
dockerfile: Dockerfile.prod | |
format: sarif | |
output-file: ${{ github.workspace }}/reports/Prod.sarif | |
- name: Upload SARIF file | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: ${{ github.workspace }}/reports | |
build: | |
name: Build and Check Prod Image | |
uses: ./.github/workflows/_build.yaml | |
with: | |
tag: ${{ github.sha }} | |
ref: ${{ github.ref }} | |
push: false |