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
# Builds MegaMekLab for Code Coverage | |
# | |
# Jobs: | |
# - code_coverage: Build MegaMekLab on the specified Operating Systems for the specified Java versions | |
# and upload the code coverage results to CodeCov.io | |
# - This job will use MM source directly for the build. | |
name: MegaMekLab CI with Code Coverage | |
# This Action Definition should be triggered only on pushes to master | |
on: | |
push: | |
branches: [ master ] | |
# Setup the Build Scan "VCS" link for all gradle invocations | |
env: | |
GRADLE_OPTS: "-Dscan.link.VCS=https://github.com/MegaMek/megameklab/commit/${{ github.sha }}" | |
jobs: | |
# Perform build of MegaMekLab for Code Coverage any time master updated. | |
code_coverage: | |
runs-on: ${{ matrix.os }} | |
# Run this job once for each combination in the matrix below. | |
strategy: | |
matrix: | |
os: [ ubuntu-latest ] # For Code QL running on *nix is sufficient | |
java-distribution: [ temurin ] | |
java-version: [ 17 ] | |
steps: | |
# Checkout the Pull Request source and put it in: ./megameklab | |
- uses: actions/checkout@v3 | |
with: | |
path: megameklab | |
# Setup composite build for MegaMekLab | |
# See: https://github.com/MegaMek/megamek/wiki/Working-With-Gradle | |
- name: Setup Composite Build for MegaMekLab | |
run: | | |
echo "includeBuild '../megamek'" >./megameklab/settings_local.gradle | |
# Checkout the latest MegaMek source and put it in: ./megamek | |
- name: Checkout MegaMek | |
uses: actions/checkout@v3 | |
with: | |
repository: MegaMek/megamek | |
path: megamek | |
# Setup the requested Java Distribution and Version from the matrix | |
- name: Set up ${{ matrix.java-distribution }} JDK ${{ matrix.java-version }} | |
uses: actions/setup-java@v3 | |
with: | |
distribution: ${{ matrix.java-distribution }} | |
java-version: ${{ matrix.java-version }} | |
# Make sure we can execute the Gradle wrapper | |
- name: Grant execute permission for gradlew (*nix or MacOS) | |
working-directory: megameklab | |
run: chmod +x gradlew | |
if: runner.os != 'Windows' | |
# Build the MegaMekLab project | |
# | |
# Directory layout: | |
# /megameklab | |
# /gradlew | |
# /megamek | |
# | |
# Output Variables: | |
# - buildScanUri | |
- name: Build with Gradle | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: build --stacktrace --max-workers=1 --scan | |
build-root-directory: megameklab | |
# If the build step fails, try to upload any test logs in case it was a unit test failure. | |
# | |
# The logs will be relative to the ./megameklab directory. | |
- name: Upload Test Logs on Failure | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: cd-failure-logs | |
path: ./megameklab/megameklab/build/reports/ | |
# Upload our Code Coverage Reports to CodeCov.io | |
- name: CodeCov.io Coverage Report | |
uses: codecov/codecov-action@v3 | |
with: | |
directory: ./megameklab/megameklab/build/reports/jacoco/test | |
fail_ci_if_error: false | |
verbose: true |