From 9964fd93682b21e0b3b2655dc9b595ea3c0eb654 Mon Sep 17 00:00:00 2001 From: Daniel McNally Date: Fri, 18 Aug 2023 11:47:09 -0400 Subject: [PATCH] Add CI w/ test coverage --- .github/workflows/main.yaml | 49 +++++++++++++++++++++++++++++++++++++ package.json | 3 +++ 2 files changed, 52 insertions(+) create mode 100644 .github/workflows/main.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..9da6c52 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,49 @@ +name: CI Build + +on: + push: + branches: [ "main" ] + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [lts, latest] + + steps: + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Install + run: | + npm ci + + - name: Build + run: | + npm run build + + - name: Lint & Format + run: | + npm run lint-check + npm run prettier-check + + - name: Tests & Coverage + run: | + npm run coverage-ci + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} diff --git a/package.json b/package.json index 2d20034..12366b9 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,11 @@ "scripts": { "build": "tsc", "coverage": "c8 npm test", + "coverage-ci": "c8 --reporter=lcov npm test", "lint": "eslint --quiet --fix --cache index.ts", + "lint-check": "eslint index.ts", "prettier": "prettier index.ts test/*.ts --write", + "prettier-check": "prettier index.ts test/*.ts --check", "test": "tsx --test test/test.ts" }, "repository": {