-
Notifications
You must be signed in to change notification settings - Fork 174
194 lines (175 loc) · 7.41 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# Builds MekHQ for CI (and CD via artifacts)
#
# Jobs:
# - ci_cd: Build MekHQ for CI/CD on the specified Operating Systems for the specified Java versions
# - This job will use MM and MML source directly for the build.
name: MekHQ 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 MekHQ any time a pull request is added or updated.
ci_cd:
runs-on: ${{ matrix.os }}
# Run this job once for each combination in the matrix below.
strategy:
matrix:
os: [ ubuntu-latest ] # For CI/CD running on *nix is sufficient
java-distribution: [ temurin ]
java-version: [ 11, 17 ]
fail-fast: false
steps:
# Checkout the Pull Request source and put it in: ./mekhq
- uses: actions/checkout@v3
with:
path: mekhq
# Setup composite build for MekHQ
# See: https://github.com/MegaMek/megamek/wiki/Working-With-Gradle
# Disabled - 25-Jun-2022 - Causing regular build failures and .
# - name: Setup Composite Build for MekHQ
# run: |
# echo "includeBuild '../megamek'" >./mekhq/settings_local.gradle
# echo "includeBuild '../megameklab'" >>./mekhq/settings_local.gradle
# 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" ]
# then
# echo "${{ github.event.pull_request.head.repo.owner.html_url }}" | awk -F/ '{print "::set-output name=mmRepo::" $4 "/megamek"}'
# echo "::set-output name=mmBranch::${{ github.event.pull_request.head.ref }}"
# else
# echo "::set-output name=mmRepo::MegaMek/megamek"
# echo "::set-output name=mmBranch::master"
# fi
# exit 0
# Checkout the latest MegaMek source and put it in: ./megamek
- name: Checkout MegaMek
uses: actions/checkout@v3
with:
# repository: ${{ steps.find_mm.outputs.mmRepo }}
# ref: ${{ steps.find_mm.outputs.mmBranch }}
repository: MegaMek/megamek
path: megamek
# Find the repo and branch to use for MML
#
# Output variables:
#
# - mmlRepo: The MML repository to use.
# - mmlBranch: The MML branch to use.
# - name: Find the Right MegaMekLab Branch
# id: find_mml
# 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 MML repo for
# a branch that has the same name as the current PR branch.
# If found it sets the mmlRepo and mmlBranch step output variables
# to that branch.
# run: |
# git ls-remote --exit-code --heads ${{ github.event.pull_request.head.repo.owner.html_url }}/megameklab.git ${{ github.event.pull_request.head.ref }}
# if [ "$?" == "0" ]
# then
# echo "${{ github.event.pull_request.head.repo.owner.html_url }}" | awk -F/ '{print "::set-output name=mmlRepo::" $4 "/megameklab"}'
# echo "::set-output name=mmlBranch::${{ github.event.pull_request.head.ref }}"
# else
# echo "::set-output name=mmlRepo::MegaMek/megameklab"
# echo "::set-output name=mmlBranch::master"
# fi
# exit 0
# Checkout the latest MegaMekLab source and put it in: ./megameklab
- name: Checkout MegaMekLab
uses: actions/checkout@v3
with:
# repository: ${{ steps.find_mml.outputs.mmlRepo }}
# ref: ${{ steps.find_mml.outputs.mmlBranch }}
repository: MegaMek/megameklab
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 "if (gradle.parent == null) includeBuild '../megamek'" >./megameklab/settings_local.gradle
# 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: mekhq
run: chmod +x gradlew
if: runner.os != 'Windows'
# Build the MekHQ project
#
# Directory layout:
# /mekhq
# /gradlew
# /megamek
# /megameklab
#
# Output Variables:
# - buildScanUri
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: clean build --no-build-cache --info --continue --stacktrace --max-workers=1 --scan
build-root-directory: mekhq
# 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 ./mekhq directory.
# - name: Upload Test Logs on Failure
# uses: actions/upload-artifact@v3
# if: failure()
# with:
# name: cd-failure-logs
# path: ./mekhq/MekHQ/build/reports/
# Upload our Code Coverage Reports to CodeCov.io
- name: CodeCov.io Coverage Report
uses: codecov/codecov-action@v3
with:
directory: ./mekhq/MekHQ/build/reports/jacoco/test
fail_ci_if_error: false
verbose: true
# If we have a buildScanUri comment on the PR
#
# NB: This only works if you're on the main MegaMek\mekhq repo
# for now due to a GitHub Actions limitation.
# CAW: temporarily halted https://github.com/thollander/actions-comment-pull-request/issues/17
# - name: Comment on PR with Build Scan URI
# uses: thollander/actions-comment-pull-request@master
# if: always() && steps.gradle_build.outputs.buildScanUri != ''
# with:
# message: Build scan available at ${{ steps.gradle_build.outputs.buildScanUri }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 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@v3
with:
name: mhq-release-win-${{ matrix.java-distribution }}-jdk${{ matrix.java-version }}
path: ./mekhq/MekHQ/build/distributions/mekhq-windows-*.zip
# Put the non-Windows release in an artifact
- name: Upload Nix/Mac Release
uses: actions/upload-artifact@v3
with:
name: mhq-release-nix-mac-${{ matrix.java-distribution }}-jdk${{ matrix.java-version }}
path: ./mekhq/MekHQ/build/distributions/*.tar