Skip to content

Commit

Permalink
GitHubActions: Add separate test coverage build (coverage.yml) with C…
Browse files Browse the repository at this point in the history
…odecov
  • Loading branch information
kevin-lee committed Apr 13, 2024
1 parent 7367364 commit 73bcf4c
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 5 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,3 @@ jobs:
echo "PR #${PR_NUMBER}"
java -version
.github/workflows/sbt-build-all.sh ${{ matrix.scala.version }} ${{ matrix.scala.report }}
- if: ${{ github.event_name == 'pull_request' && matrix.scala.report == 'report' }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
83 changes: 83 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: "Test Coverage"

on:
push:
branches:
- 'main'

pull_request:
branches:
- main

env:
GH_SBT_OPTS: "-Xss64m -Xms1024m -XX:MaxMetaspaceSize=1G -Xmx4G -XX:MaxInlineLevel=18 -XX:+UnlockExperimentalVMOptions"
GH_JVM_OPTS: "-Xss64m -Xms1024m -XX:MaxMetaspaceSize=1G -Xmx4G -XX:MaxInlineLevel=18 -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler"

jobs:

build:
runs-on: ubuntu-latest

strategy:
matrix:
scala:
- { name: "Scala 3.3", version: "3.3.1", binary-version: "3", java-version: "11", java-distribution: "temurin", report: "report" }

steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: ${{ matrix.scala.java-version }}
distribution: ${{ matrix.scala.java-distribution }}

- name: Cache SBT
uses: actions/cache@v4
with:
path: |
~/.ivy2/cache
~/.cache/coursier
~/.sbt
key: ${{ runner.os }}-sbt-${{ matrix.scala.binary-version }}-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('**/build.properties') }}
restore-keys: |
${{ runner.os }}-sbt-${{ matrix.scala.binary-version }}-
- name: "[Codecov] Report ${{ matrix.scala.name }} ${{ matrix.scala.version }} - ${{ github.run_number }}"
if: ${{ matrix.scala.report == 'report' && github.event_name == 'push' }}
env:
CURRENT_BRANCH_NAME: ${{ github.ref }}
RUN_ID: ${{ github.run_id }}
RUN_NUMBER: ${{ github.run_number }}
JVM_OPTS: ${{ env.GH_JVM_OPTS }}
SBT_OPTS: ${{ env.GH_SBT_OPTS }}
run: |
echo "[BEFORE]CURRENT_BRANCH_NAME=${CURRENT_BRANCH_NAME}"
export CURRENT_BRANCH_NAME="${CURRENT_BRANCH_NAME#refs/heads/}"
echo " [AFTER]CURRENT_BRANCH_NAME=${CURRENT_BRANCH_NAME}"
echo "RUN_ID=${RUN_ID}"
echo "RUN_NUMBER=${RUN_NUMBER}"
echo "Push #${PUSH_NUMBER}"
java -version
.github/workflows/sbt-build-all.sh ${{ matrix.scala.version }} ${{ matrix.scala.report }}
- name: "[Codecov] Report ${{ matrix.scala.name }} ${{ matrix.scala.version }} - ${{ github.run_number }} - PR-#${{ github.event.pull_request.number }} - ${{ github.run_number }}"
if: ${{ matrix.scala.report == 'report' && github.event_name == 'pull_request' }}
env:
CURRENT_BRANCH_NAME: ${{ github.base_ref }}
RUN_ID: ${{ github.run_id }}
RUN_NUMBER: ${{ github.run_number }}
PR_NUMBER: ${{ github.event.pull_request.number }}
JVM_OPTS: ${{ env.GH_JVM_OPTS }}
SBT_OPTS: ${{ env.GH_SBT_OPTS }}
run: |
echo "Rull request to the '${CURRENT_BRANCH_NAME}' branch"
echo "RUN_ID=${RUN_ID}"
echo "RUN_NUMBER=${RUN_NUMBER}"
echo "PR #${PR_NUMBER}"
java -version
.github/workflows/sbt-build-all.sh ${{ matrix.scala.version }} ${{ matrix.scala.report }}
- if: ${{ matrix.scala.report == 'report' }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
test_report:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')

strategy:
matrix:
Expand Down

0 comments on commit 73bcf4c

Please sign in to comment.