Skip to content

Commit

Permalink
Update GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mweirauch committed Sep 7, 2024
1 parent 59ddd59 commit 5262cf3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 28 deletions.
9 changes: 0 additions & 9 deletions .github/maven-settings.xml

This file was deleted.

39 changes: 20 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,61 @@ 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]
java: [11, 17]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0 # SonarCloud doesn't like shallow clones

- name: Setup Java
uses: joschi/setup-jdk@v2
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java }}
cache: maven
server-id: sonatype-nexus-snapshots
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD

- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- 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
uses: actions/cache@v2
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: 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: SonarCloud analysis
if: env.SONAR_TOKEN != null && matrix.java == env.DEFAULT_JAVA
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
- 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 --settings=.github/maven-settings.xml -DskipTests=true -Dbasepom.check.skip-all=true
run: mvn -B deploy -DskipTests=true -Dbasepom.check.skip-all=true

0 comments on commit 5262cf3

Please sign in to comment.