Merge pull request #88 from sakata1222/chore/codecov-v5 #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a Java project with Gradle | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle | |
name: Java CI with Gradle | |
on: | |
push: | |
branches: [ main ] | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Gradle binary cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/wrapper/ | |
key: gradle-wrapper-${{ hashFiles('plugin/src/functionalTest/resources/gradleVersions.csv') }} | |
restore-keys: | | |
gradle-wrapper- | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
# Tests for previous gradle do not work with JDK 17, so run the test with JDK11 | |
java-version: 11 | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew build --stacktrace | |
# sonarqube analysis does not support JDK 11 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
- name: Analysis with Gradle | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
# the plugin:functionalTest task uses older gradle which does not support JDK17 | |
run: ./gradlew sonar -x plugin:functionalTest --stacktrace | |
- uses: codecov/codecov-action@v5 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
with: | |
file: plugin/build/reports/jacoco/test/jacocoTestReport.xml | |
flags: unittests | |
fail_ci_if_error: true | |
verbose: true | |
- name: Publish gradle plugin | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: | | |
echo "gradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }}" > ~/.gradle/gradle.properties | |
echo "gradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}" >> ~/.gradle/gradle.properties | |
./gradlew publishPlugins |