Closed JoernBerkefeld closed 1 year ago
Hey @JoernBerkefeld , we just started using this action as well, and had to work through a bit of this as well. We setup an action to check in a current coverage file anytime a PR was merged, and then you will always have that base file to reference in this action. This seems to be working for us so far, but I can post an update here if we run into anything. (And I actually came to the issues here to report that the action is using the soon-to-be-deprecated github set-output
command. I've fixed that in a fork, and we're currently referencing that fork in our action - but I'll submit an issue and PR for that here).
This is our action that does that:
name: Unit Tests
on:
pull_request:
types: [ opened, synchronize, reopened, closed ]
jobs:
unit-test-server:
name: Unit Test Server
runs-on: ubuntu-latest
steps:
- name: Check Out Head
if: github.event.pull_request.merged == false
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Check Out Base
if: github.event.pull_request.merged == true
uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Node Modules
run: |
cd server && yarn install
- name: Run unit tests
run: |
cd server && yarn test
- name: Test coverage report
if: github.event.pull_request.merged == false
# Change back to the official action once the github dependencies are fixed
# uses: sidx1024/report-nyc-coverage-github-action@v1.2.6
uses: jfkriz/report-nyc-coverage-github-action@v1.2.7
with:
coverage_file: ./server/coverage/coverage-summary.json
base_coverage_file: ./server/.nyc-coverage/coverage-summary.json
comment_template_file: ./server/.nyc-coverage/nyc-coverage-template.md
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Commit new coverage summary to repo
if: github.event.pull_request.merged == true
run: |
cd server
cp coverage/coverage-summary.json .nyc-coverage
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -a -m "Update nyc coverage summary for server"
- name: Push new coverage summary to repo
if: github.event.pull_request.merged == true
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.base_ref }}
Hi @JoernBerkefeld, thanks for opening this issue. I've fixed the problem that was preventing the comparison with base branch. And also you can use the workflows (https://github.com/sidx1024/report-nyc-coverage-github-action/tree/main/.github/workflows) in the repo itself to see how it can be used.
I appreciate that you built this but it's really no use to anyone if there are no proper examples on how to use it. your own test pull requests don't show the base comparison thing and I'm trying hard to understand the complex workflow structure in your repo.
Can you PLEASE provide a SIMPLIFIED one-file example of a workflow configuration that actually works?