-
Notifications
You must be signed in to change notification settings - Fork 70
117 lines (100 loc) · 3.54 KB
/
ci-earthly-gradle.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
name: Earthly/Gradle 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 Maven
on:
push:
paths-ignore:
# Generic files to ignore for building
- '*.md'
- 'images/**'
# These ignores are specific to a cross-build against Maven
- 'pom.xml'
- 'mvnw*' # Wraper scripts
- '.mvn/**'
- '.github/workflows/*maven*'
# These ignores are specific to this project
- 'run-with-maven.sh'
pull_request:
paths-ignore:
# Generic files to ignore for building
- '*.md'
- 'images/**'
# These ignores are specific to a cross-build against Maven
- 'pom.xml'
- 'mvnw*' # Wrapper scripts
- '.mvn/**'
- '.github/workflows/*maven*'
# These ignores are specific to this project
- 'run-with-maven.sh'
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 Gradle caches
uses: actions/cache@master
env:
cache-name: gradle-cache
with:
path: ~/.gradle
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{hashFiles('**/build.gradle') }}
# TODO: See discussion: https://github.com/jeremylong/DependencyCheck/issues/2560#issuecomment-702098748
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-gradle
- name: Execute run script
run: earthly --secret OWASP_NVD_API_KEY +run-with-gradle
# 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: build/libs/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: build/docs/javadoc/
- name: Save Javadoc HTML Jar for main
uses: actions/upload-artifact@v4
with:
name: javadoc-jar-main
if-no-files-found: error
path: build/libs/modern-java-practices-0-SNAPSHOT-javadoc.jar
# Generate coverage report
- name: Save coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
if-no-files-found: error
path: build/reports/jacoco/test/
- name: Generate coverage badge
uses: cicirello/jacoco-badge-generator@v2
with:
badges-directory: images
jacoco-csv-file: build/reports/jacoco/test/jacocoTestReport.csv
# To avoid conflicts with the Maven build, only generate the badge
# there. For Gradle only projects: REMOVE THIS LINE.
generate-coverage-badge: false
generate-branches-badge: false
generate-summary: false