diff --git a/.github/workflows/codacy-coverage-reporter.yml b/.github/workflows/codacy-coverage-reporter.yml deleted file mode 100644 index 248fc411..00000000 --- a/.github/workflows/codacy-coverage-reporter.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Code Coverage - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Use Node.js 12.x - uses: actions/setup-node@v1 - with: - node-version: 12.x - - run: npm ci - - run: npm run build --if-present - - run: npm run coverage-publish - env: - CODACY_PROJECT_TOKEN: ${{secrets.CODACY_PROJECT_TOKEN}} diff --git a/.github/workflows/nodejs-ci-action.yml b/.github/workflows/nodejs-ci-action.yml index e772a1cd..c1de8925 100644 --- a/.github/workflows/nodejs-ci-action.yml +++ b/.github/workflows/nodejs-ci-action.yml @@ -11,19 +11,55 @@ on: jobs: build: - + name: Build and test runs-on: ubuntu-latest - strategy: matrix: node-version: [10.x, 12.x] steps: - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} + - name: Test on Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - run: npm ci - run: npm run build --if-present - run: npm test + + coverage: + name: Code coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Generate coverage report + uses: actions/setup-node@v1 + with: + node-version: 12.x + - run: npm ci + - run: npm run build --if-present + - run: npm run coverage + - name: Upload coverage report to storage + uses: actions/upload-artifact@v1 + with: + name: coverage + path: coverage/lcov.info + + publish: + name: Publish code coverage report + needs: coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Download coverage report from storage + uses: actions/download-artifact@v1 + with: + name: coverage + - name: Upload coverage report to codacy + uses: actions/setup-node@v1 + with: + node-version: 12.x + - run: | + ( [[ "${CODACY_PROJECT_TOKEN}" != "" ]] && npm run coverage-publish ) || echo "Coverage report not published" + env: + CODACY_PROJECT_TOKEN: ${{secrets.CODACY_PROJECT_TOKEN}} diff --git a/package.json b/package.json index bc572aae..9f77a2c2 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "pretest": "npm run lint", "test": "mocha test/**/*.js", "coverage": "nyc --reporter=lcov --reporter=text npm run test", - "precoverage-publish": "npm run coverage", "coverage-publish": "wget -qO - https://coverage.codacy.com/get.sh | bash -s report -l JavaScript -r coverage/lcov.info", "generate-docs": "jsdoc --configure .jsdoc.json --verbose", "release": "standard-version"