Skip to content

Commit

Permalink
build: Reestructure Github Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
felipebz committed May 30, 2024
1 parent bd12517 commit 1f2962d
Showing 1 changed file with 53 additions and 41 deletions.
94 changes: 53 additions & 41 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,85 @@ on:
branches:
- main

env:
JAVA_VERSION: 21

jobs:
integration-tests:
name: IT
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sqVersion:
- LATEST_RELEASE[9.9]
- LATEST_RELEASE[10.5]
- 10.6-SNAPSHOT
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
java-version: ${{ env.JAVA_VERSION }}

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Build with Gradle
run: ./gradlew build publishToMavenLocal -x dokkaJavadoc -x test --refresh-dependencies
run: ./gradlew build publishToMavenLocal --build-cache

- name: Build custom rules example
run: ./gradlew build -p plsql-custom-rules

- if: ${{ !contains(matrix.sqVersion, 'SNAPSHOT') }}
name: Run integration test
run: ./gradlew integrationTest -Dsonar.runtimeVersion=${{ matrix.sqVersion }} --info

- if: ${{ contains(matrix.sqVersion, 'SNAPSHOT') }}
name: Run integration test
run: |
curl -s -L "https://nexus.felipezorzo.com.br/service/rest/v1/search/assets/download?repository=maven-snapshots&maven.groupId=org.sonarsource.sonarqube&maven.artifactId=sonar-application&maven.extension=zip&sort=version&maven.baseVersion=${{ matrix.sqVersion }}" \
-u "$AUTH_REPOSITORY" \
-o sonar-zpa-plugin/sonar-application-${{ matrix.sqVersion }}.zip
./gradlew integrationTest -Dsonar.zipFile=sonar-application-${{ matrix.sqVersion }}.zip --info
env:
AUTH_REPOSITORY: ${{ secrets.AUTH_REPOSITORY }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: '**/build/'
retention-days: 1

windows-build:
name: Test on Windows
runs-on: windows-latest
integration-tests:
name: IT
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sqVersion:
- LATEST_RELEASE[9.9]
- LATEST_RELEASE[10.5]
- 10.6-SNAPSHOT
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
java-version: ${{ env.JAVA_VERSION }}

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Build with Gradle
run: ./gradlew test

linux-build:
name: Build and release
needs: [integration-tests, windows-build]
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts

- run: ls -lR

#- if: ${{ !contains(matrix.sqVersion, 'SNAPSHOT') }}
# name: Run integration test
# run: ./gradlew integrationTest -Dsonar.runtimeVersion=${{ matrix.sqVersion }} --info
#
#- if: ${{ contains(matrix.sqVersion, 'SNAPSHOT') }}
# name: Run integration test
# run: |
# curl -s -L "https://nexus.felipezorzo.com.br/service/rest/v1/search/assets/download?repository=maven-snapshots&maven.groupId=org.sonarsource.sonarqube&maven.artifactId=sonar-application&maven.extension=zip&sort=version&maven.baseVersion=${{ matrix.sqVersion }}" \
# -u "$AUTH_REPOSITORY" \
# -o sonar-zpa-plugin/sonar-application-${{ matrix.sqVersion }}.zip
# ./gradlew integrationTest -Dsonar.zipFile=sonar-application-${{ matrix.sqVersion }}.zip --info
# env:
# AUTH_REPOSITORY: ${{ secrets.AUTH_REPOSITORY }}

release:
name: Release
needs: integration-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -81,14 +96,11 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
java-version: ${{ env.JAVA_VERSION }}

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Build with Gradle
run: ./gradlew build --refresh-dependencies

- if: github.ref == 'refs/heads/main'
name: Run SonarQube Scanner
run: ./gradlew sonar --info
Expand Down Expand Up @@ -116,7 +128,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
java-version: ${{ env.JAVA_VERSION }}

- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@v3

0 comments on commit 1f2962d

Please sign in to comment.