Skip to content

Commit

Permalink
Cleaned up CI scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rjhancock committed Jul 5, 2024
1 parent a4da5e4 commit 5152463
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 103 deletions.
11 changes: 5 additions & 6 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ coverage:
status:
project:
default:
target: auto # auto compares coverage to the previous base commit
threshold: 1% # the leniency in hitting the target
informational: true # makes project checks informational only, not failing
target: auto
threshold: 1%
informational: true

patch:
default:
informational: true # makes patch checks informational only, not failing
informational: true

fixes:
- "megameklab/::" # reduce root e.g., "before/path/" => "path/"
- "megameklab/::"

ignore:
- "megamek"

github_checks:
# https://docs.codecov.io/docs/github-checks-beta#disabling-github-checks-patch-annotations-via-yaml
annotations: false
34 changes: 4 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
# Builds MegaMekLab for CI (and CD via artifacts)
#
# Jobs:
# - ci_cd: Build MegaMekLab for CI/CD on the specified Operating Systems for the specified Java versions
# - This job will use the MM source directly for the build.
name: MegaMekLab CI with Gradle

# This Action Definition should be triggered only on
# Pull Requests being added/updated against master.
on:
pull_request:
branches: [master]

# Setup the Build Scan "VCS" link for all gradle invocations
env:
GRADLE_OPTS: "-Dscan.link.VCS=${{ github.event.pull_request.html_url }}"

jobs:
# Perform CI (and CD as an artifact) of MegaMekLab any time a pull request is added or updated.
ci_cd:
runs-on: ${{ matrix.os }}

outputs:
mmRepo: ${{ steps.find_mm.outputs.mmRepo }}
mmBranch: ${{ steps.find_mm.outputs.mmBranch }}

# Run this job once for each combination in the matrix below.
strategy:
matrix:
os: [ubuntu-latest] # For CI/CD running on *nix is sufficient
Expand All @@ -33,26 +23,14 @@ jobs:
fail-fast: false

steps:
# Checkout the Pull Request source and put it in: ./megameklab
- name: Checking out MegaMekLab
uses: actions/checkout@v4
with:
path: megameklab

# Find the repo and branch to use for MM
#
# Output variables:
#
# - mmRepo: The MM repository to use.
# - mmBranch: The MM branch to use.
- name: Find the Right MegaMek Branch
id: find_mm
# Override bash so that it doesn't fail fast (the default) if we can't find the branch
shell: bash {0}
# This shell script searches the PR submitter's MM repo for
# a branch that has the same name as the current PR branch.
# If found it sets the `mmRepo` and `mmBranch` step output variables
# to that branch.
run: |
git ls-remote --exit-code --heads ${{ github.event.pull_request.head.repo.owner.html_url }}/megamek.git ${{ github.event.pull_request.head.ref }}
if [ "$?" == "0" ]
Expand All @@ -65,15 +43,13 @@ jobs:
fi
exit 0
# Checkout the latest MegaMek source and put it in: ./megamek
- name: Checkout MegaMek
uses: actions/checkout@v4
with:
repository: ${{ steps.find_mm.outputs.mmRepo }}
ref: ${{ steps.find_mm.outputs.mmBranch }}
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@v4
with:
Expand All @@ -82,37 +58,35 @@ jobs:

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
build-scan-terms-of-use-agree: "yes"

- name: Build with Gradle
working-directory: megameklab
run: ./gradlew build --stacktrace --scan

# 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@v4
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@v4
with:
directory: ./megameklab/megameklab/build/reports/jacoco/test
fail_ci_if_error: false
verbose: true

# Put the Windows Release in an artifact
# NB: Due to a GitHub Actions limitation we won't know what the filename is in order to display it somewhere.
- name: Upload Windows Release
uses: actions/upload-artifact@v4
with:
name: mml-release-win-${{ matrix.java-distribution }}-jdk${{ matrix.java-version }}
path: ./megameklab/megameklab/build/distributions/megameklab-windows-*.zip

# Put the non-Windows release in an artifact
- name: Upload Nix/Mac Release
uses: actions/upload-artifact@v4
with:
Expand Down
19 changes: 1 addition & 18 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,33 @@
# 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
os: [ubuntu-latest]
java-distribution: [temurin]
java-version: [17]

steps:
# Checkout the Pull Request source and put it in: ./megameklab
- uses: actions/checkout@v4
with:
path: megameklab

# Checkout the latest MegaMek source and put it in: ./megamek
- name: Checkout MegaMek
uses: actions/checkout@v4
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@v4
with:
Expand All @@ -54,17 +41,13 @@ jobs:
working-directory: megameklab
run: ./gradlew test

# 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@v4
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@v4
with:
Expand Down
31 changes: 1 addition & 30 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
name: "CodeQL"

on:
Expand All @@ -27,10 +17,9 @@ jobs:
mmRepo: ${{ steps.find_mm.outputs.mmRepo }}
mmBranch: ${{ steps.find_mm.outputs.mmBranch }}

# Run this job once for each combination in the matrix below.
strategy:
matrix:
os: [ubuntu-latest] # For Code QL running on *nix is sufficient
os: [ubuntu-latest]
language: ["java"]
java-distribution: [temurin]
java-version: [17]
Expand All @@ -42,20 +31,9 @@ jobs:
with:
path: megameklab

# Find the repo and branch to use for MM
#
# Output variables:
#
# - mmRepo: The MM repository to use.
# - mmBranch: The MM branch to use.
- name: Find the Right MegaMek Branch
id: find_mm
# Override bash so that it doesn't fail fast (the default) if we can't find the branch
shell: bash {0}
# This shell script searches the PR submitter's MM repo for
# a branch that has the same name as the current PR branch.
# If found it sets the `mmRepo` and `mmBranch` step output variables
# to that branch.
run: |
git ls-remote --exit-code --heads ${{ github.event.pull_request.head.repo.owner.html_url }}/megamek.git ${{ github.event.pull_request.head.ref }}
if [ "$?" == "0" ]
Expand All @@ -68,30 +46,23 @@ jobs:
fi
exit 0
# Checkout the latest MegaMek source and put it in: ./megamek
- name: Checkout MegaMek
uses: actions/checkout@v4
with:
repository: ${{ steps.find_mm.outputs.mmRepo }}
ref: ${{ steps.find_mm.outputs.mmBranch }}
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@v4
with:
distribution: ${{ matrix.java-distribution }}
java-version: ${{ matrix.java-version }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
queries: +security-and-quality

- name: Setup Gradle
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/dependency-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Gradle Dependency Submission

on:
push:
branches:
- main

jobs:
dependency-submission:
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v4

- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@v3
with:
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
build-scan-terms-of-use-agree: "yes"
24 changes: 5 additions & 19 deletions .github/workflows/nightly-ci.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
# Builds MegaMekLab for CI each Night
#
# Jobs:
# - nightly_ci: Build MegaMekLab for CI across multiple platforms and Java versions.
name: MegaMekLab Nightly CI

on:
schedule:
# Nightly at Midnight (UTC)
# ref: https://crontab.guru/every-night
- cron: "0 0 * * *"

# 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:
nightly_ci:
runs-on: ${{ matrix.os }}

# Run this job once for each combination in the matrix below.
strategy:
matrix:
os: [ubuntu-latest]
Expand All @@ -29,19 +21,16 @@ jobs:
name: Nightly MegaMekLab CI ${{ matrix.os }} on ${{ matrix.java-distribution }} JDK ${{ matrix.java-version }}

steps:
# Checkout the latest source and put it in: ./megameklab
- uses: actions/checkout@v4
with:
path: megameklab

# Checkout the latest MegaMek source and put it in: ./megamek
- name: Checkout MegaMek
uses: actions/checkout@v4
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@v4
with:
Expand All @@ -50,10 +39,14 @@ jobs:

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
build-scan-terms-of-use-agree: "yes"

- name: Build with Gradle
working-directory: megameklab
run: ./gradlew clean build -x test --continue --stacktrace --scan
run: ./gradlew clean build --stacktrace --scan

- name: Upload Test Logs on Failure
uses: actions/upload-artifact@v4
Expand All @@ -62,19 +55,12 @@ jobs:
name: ${{ matrix.os }}-${{ matrix.java-distribution }}-jdk${{ matrix.java-version }}-ci-failure-logs
path: megameklab/megameklab/build/reports/

# Put the non-Windows Release in an artifact
#
# NB: Due to a GitHub Actions limitation we won't know what the filename is in order to display it somewhere.
- name: Upload Nix/Mac Releases
uses: actions/upload-artifact@v4
if: always() && matrix.os == 'ubuntu-latest'
with:
name: mml-release-nix-mac-${{ matrix.java-distribution }}-jdk${{ matrix.java-version }}
path: megameklab/megameklab/build/distributions/megameklab-unix-*.tar.gz

# Put the Windows Release in an artifact
#
# NB: Due to a GitHub Actions limitation we won't know what the filename is in order to display it somewhere.
- name: Upload Windows Release
uses: actions/upload-artifact@v4
with:
Expand Down

0 comments on commit 5152463

Please sign in to comment.