diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36116dc..21a6719 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,29 +1,52 @@ name: CI on: - push: - branches: - - '**' pull_request: branches: - '**' + types: + - opened + - synchronize + - reopened jobs: - build: - + build-and-test: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install dependencies + run: npm install + + - name: Run Code Climate Test Reporter before-build + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + run: | + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + chmod +x ./cc-test-reporter + ./cc-test-reporter before-build - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '20' + - name: Run tests with coverage + run: npm run coverage - - name: Install dependencies - run: yarn install + - name: Format coverage report for Code Climate + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + run: | + ./cc-test-reporter format-coverage coverage/lcov.info \ + --input-type lcov \ + --output coverage/codeclimate.json - - name: Run tests - run: yarn test + - name: Upload coverage to Code Climate + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + run: | + ./cc-test-reporter upload-coverage \ + --input coverage/codeclimate.json diff --git a/package.json b/package.json index bf970f9..03cc837 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "dev": "tsc-watch --onSuccess 'node dist/index.js'", "test": "jest", "test:watch": "jest --watch", - "prebuild": "rimraf ./dist" + "prebuild": "rimraf ./dist", + "coverage": "jest --coverage" }, "files": [ "dist"