From e6a2ea6998833decfa114ce76cd7f96d5c586d06 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Mon, 7 Sep 2020 00:39:55 -0400 Subject: [PATCH] chore: Move Regression coverage to PR comment --- .github/workflows/coverage-report.yml | 60 +++++++++++++++++++++++++++ .travis.yml | 4 -- 2 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/coverage-report.yml diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml new file mode 100644 index 0000000000..98a2b371de --- /dev/null +++ b/.github/workflows/coverage-report.yml @@ -0,0 +1,60 @@ +name: Regression Tests Coverage Report + +on: + pull_request_target: + paths: + - "examples/**" + - "test/**" + - "!examples/landmarks/**" + +jobs: + report: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + ref: refs/pull/${{ github.event.pull_request.number }}/head + + - name: Install dependencies + run: npm ci + + - name: Run coverage report + run: | + node test/util/report.js >> coverage.log || true + + - name: Comment on PR + uses: actions/github-script@0.9.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const fs = require('fs'); + const commentBody = '```' + fs.readFileSync('coverage.log', 'utf8') + '```'; + + if (commentBody.length === 0) { + return + } + // Get the existing comments. + const {data: comments} = await github.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.number, + }) + // Find any comment already made by the bot. + const botComment = comments.find(comment => comment.user.id === 41898282) + + if (botComment) { + await github.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: botComment.id, + body: commentBody + }) + } else { + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.number, + body: commentBody + }) + } diff --git a/.travis.yml b/.travis.yml index cacaf643c2..b098748de8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,10 +29,6 @@ jobs: name: Spellcheck script: npm run lint:spelling env: ALLOW_FAILURE=true - - stage: Lint - name: Regression Tests Coverage Report - script: node test/util/report.js - env: ALLOW_FAILURE=true - stage: Test name: AVA Regression Tests