feat: [M3-7128] - Coverage Report - Part 1 #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Code Coverage | |
on: [pull_request] | |
jobs: | |
base_branch_coverage: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.base_ref }} # The base branch of the PR (develop) | |
- name: Use Node.js v18.14.0 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18.14" | |
- name: Install dependencies | |
run: yarn | |
### TEMP FOR TESTING | |
- name: Yarn test with coverage | |
run: yarn workspace linode-manager run test:ci | |
### | |
- name: Run base branch coverage and write to a file | |
run: | | |
ref_coverage_value=$(yarn coverage:get) | |
echo "$ref_coverage_value" > ref_code_coverage.txt | |
### TEMP FOR TESTING | |
current_branch_coverage: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js v18.14.0 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18.14" | |
- name: Download code coverage report from base branch | |
uses: actions/download-artifact@v3 | |
with: | |
name: ref_code_coverage | |
path: ref_code_coverage.txt | |
- name: Install dependencies | |
run: yarn | |
- name: Run current branch coverage and write to a file | |
run: | | |
current_coverage_value=$(yarn coverage:get) | |
echo "$current_coverage_value" > current_code_coverage.txt | |
- name: Generate Comment with Code Coverage | |
run: | | |
base_coverage=$(cat ref_code_coverage.txt) | |
current_coverage=$(cat current_code_coverage.txt) | |
comment_message="Base Coverage: $base_coverage\nCurrent Coverage: $current_coverage" | |
echo "$comment_message" > updated_comment.txt | |
- name: Log Code Coverage | |
run: | | |
base_coverage=$(cat ref_code_coverage.txt) | |
current_coverage=$(cat current_code_coverage.txt) | |
comment_message="Base Coverage: $base_coverage\nCurrent Coverage: $current_coverage" | |
echo "Coverage: $comment_message" | |
### THIS WILL FAIL | |
- name: Post Comment | |
uses: mshick/add-pr-comment@v2 | |
with: | |
message: | | |
<strong>Coverage Report</strong>:\n | |
$(cat updated_comment.txt) | |
### |