-
Notifications
You must be signed in to change notification settings - Fork 70
146 lines (126 loc) · 4.55 KB
/
ci-earthly-maven.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
name: Earthly/Maven CI
env:
OWASP_NVD_API_KEY: ${{ secrets.OWASP_NVD_API_KEY }}
# Workaround for: https://github.com/earthly/earthly/issues/4220
EARTHLY_DISABLE_REMOTE_REGISTRY_PROXY: true
# Ignore cross-build files with Gradle
on:
push:
paths-ignore:
# Generic files to ignore for building
- '*.md'
- 'images/**'
# These ignores are specific to a cross-build against Gradle
- 'build.gradle'
- 'gradle/**' # Directory is distinct from files in GitHub ignores
- 'gradle*' # Wrapper scripts and properties
- '.gradle'
- '.github/workflows/*gradle*'
# These ignores are specific to this project
- 'run-with-gradle.sh'
pull_request:
paths-ignore:
# Generic files to ignore for building
- '*.md'
- 'images/**'
# These ignores are specific to a cross-build against Gradle
- 'build.gradle'
- 'gradle/**' # Directory is distinct from files in GitHub ignores
- 'gradle*' # Wrapper scripts and properties
- '.gradle'
- '.github/workflows/*gradle*'
# These ignores are specific to this project
- 'run-with-gradle.sh'
workflow_dispatch:
jobs:
build:
name: Builds and tests
runs-on: ubuntu-latest
steps:
- name: Use Earthly
uses: earthly/actions-setup@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# The version in CI should match the version you use locally.
# This is a manual step.
# Using "latest" to force CI warnings if Earthfile is outdated
version: "latest"
- name: Clone repository
uses: actions/checkout@v4
- name: Restore Maven caches
uses: actions/cache@master
env:
cache-name: maven-cache
with:
path: ~/.m2
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Build and test
run: earthly --secret OWASP_NVD_API_KEY +build-with-maven
- name: Execute run script
run: earthly --secret OWASP_NVD_API_KEY +run-with-maven
# Save artifacts for build
# See Earthfile that copies these from container to local
- name: Save Jar for main
uses: actions/upload-artifact@v4
with:
name: jar-main
if-no-files-found: error
path: target/modern-java-practices-0-SNAPSHOT.jar
# Javadoc HTML and jars
- name: Save Javadoc HTML for main
uses: actions/upload-artifact@v4
with:
name: javadoc-html-main
if-no-files-found: error
path: target/reports/apidocs/
- name: Save Javadoc HTML Jar for main
uses: actions/upload-artifact@v4
with:
name: javadoc-jar-main
if-no-files-found: error
path: target/modern-java-practices-0-SNAPSHOT-javadoc.jar
- name: Save Javadoc HTML for unit tests
uses: actions/upload-artifact@v4
with:
name: javadoc-html-unittests
if-no-files-found: error
path: target/reports/testapidocs/
- name: Save Javadoc HTML Jar for unit tests
uses: actions/upload-artifact@v4
with:
name: javadoc-jar-unittests
if-no-files-found: error
path: target/modern-java-practices-0-SNAPSHOT-test-javadoc.jar
# Coverage coverage report
- name: Save coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
if-no-files-found: error
path: target/site/jacoco/
# Generate coverage badge for README
# Gradle builds are similar but will require configuration the path for the
# CSV JaCoCo report.
- name: Generate coverage badge
uses: cicirello/jacoco-badge-generator@v2
with:
badges-directory: images
generate-branches-badge: false
generate-summary: false
# The saved badge does not appear when you pull code locally
- name: Add coverage to CI repo
# Limit frontpage badge to mainline code, not branches or PRs
if: ${{ github.ref == 'refs/head/master' }}
run: |
cd images
if [[ ! -z "$(git status --porcelain *.svg)" ]]; then
git config --global user.name 'github-actions'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add *.svg
git commit -m 'Autogenerated coverage badge'
git push
fi