-
Notifications
You must be signed in to change notification settings - Fork 19
63 lines (54 loc) · 2.05 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
name: CI
on:
push:
pull_request:
workflow_dispatch:
env:
DEFAULT_JAVA: 11
SONAR_JAVA: 17
TARGET_JAVA_CLASS_FILE_VERSION: 52 # Java 8
jobs:
test:
name: Test
strategy:
matrix:
java: [11, 17, 21]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # SonarCloud doesn't like shallow clones
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: temurin
cache: maven
server-id: sonatype-nexus-snapshots
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD
- name: Build with Maven
run: mvn -B clean verify
- name: Verify Java class file version
run: 'javap -verbose target/classes/io/github/mweirauch/micrometer/jvm/extras/ProcessMemoryMetrics.class | grep "major version: ${{ env.TARGET_JAVA_CLASS_FILE_VERSION }}"'
- name: Cache SonarCloud packages
if: env.SONAR_TOKEN != null && matrix.java == env.SONAR_JAVA
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: SonarCloud analysis
if: env.SONAR_TOKEN != null && matrix.java == env.SONAR_JAVA
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B jacoco:report jacoco:report-integration sonar:sonar -Dsonar.organization=mweirauch-github -Dsonar.projectKey=mweirauch_micrometer-jvm-extras -Dsonar.host.url=https://sonarcloud.io
- name: Publish Snapshot
if: env.OSSRH_USERNAME != null && matrix.os == 'ubuntu-latest' && matrix.java == env.DEFAULT_JAVA && github.ref == 'refs/heads/main'
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
run: mvn -B deploy -DskipTests=true -Dbasepom.check.skip-all=true