Skip to content

Commit

Permalink
chore: fix sonar workflow (redhat-developer#671)
Browse files Browse the repository at this point in the history
* chore: fix sonar workflow

Signed-off-by: Stephane Bouchet <[email protected]>

* chore: fix sonar workflow

Signed-off-by: Stephane Bouchet <[email protected]>

---------

Signed-off-by: Stephane Bouchet <[email protected]>
  • Loading branch information
sbouchet authored Jan 26, 2024
1 parent 29a4d80 commit 3d2f8c6
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 108 deletions.
85 changes: 81 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# 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

# Main CI
name: Java CI with Gradle

on:
Expand All @@ -9,9 +7,29 @@ on:
pull_request:
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:

build:
configure_sonar:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'

steps:
- name: Save Sonar config on PR
run: |
mkdir -p ./prInfo
echo ${{ github.event.number }} > ./prInfo/PR
echo ${{ github.base_ref }} > ./prInfo/base_ref
echo ${{ github.head_ref }} > ./prInfo/head_ref
- uses: actions/upload-artifact@v3
with:
name: prInfo
path: prInfo/

ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -36,3 +54,62 @@ jobs:
path: |
build/test-results/**/*.xml
build/jacoco/
kubernetes-integration-tests:
runs-on: ubuntu-latest
needs: ci

steps:
- uses: actions/checkout@v3
# TODO remove locally building common-ui-test-library after new release of common-ui-test-library
- name: 'Clone common-ui-test-library to Maven Local repository'
run: |
git clone --branch 174 https://github.com/richard0202/intellij-common-ui-test-library.git ../common-ui-test-library
- uses: burrunan/gradle-cache-action@v1
name: Build common-ui-test-library
with:
build-root-directory: ../common-ui-test-library
arguments: publishToMavenLocal
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'gradle'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 #v0.5.0
name: Start cluster
with:
version: v0.11.1
- name: Setup cluster
run: |
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.19.1/install.sh | bash -s v0.19.1
kubectl create -f https://operatorhub.io/install/service-binding-operator.yaml
kubectl create -f https://operatorhub.io/install/stable/cloud-native-postgresql.yaml
nb=0
echo -n "Waiting for operator to show up "
while [ "$nb" != "2" ]
do
echo -n "."
sleep 1
nb=`kubectl get pods -n operators --no-headers --ignore-not-found | grep Running | wc -l`
done
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Play integration tests
run: ./gradlew integrationTest --continue --no-daemon
#- name: Play integration UI tests
# run: |
# echo "${{ secrets.IDEA_KEY_PASSPHRASE }}" | gpg --decrypt --passphrase-fd 0 --pinentry-mode loopback --output idea_license_token/idea.key idea_license_token/idea.key.gpg
# export DISPLAY=:99.0
# Xvfb -ac :99 -screen 0 1920x1080x16 &
# sleep 10
# ./gradlew integrationUITest --info --continue
- uses: actions/upload-artifact@v3
if: always()
with:
name: kubernetes-integration-tests-reports
path: |
build/test-results/**/*.xml
build/jacoco/
100 changes: 0 additions & 100 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -1,100 +0,0 @@
name: Play Integration Tests
on:
workflow_run:
workflows: [ "Java CI with Gradle" ]
types:
- completed
jobs:

configure_sonar:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'

steps:
- name: Save Sonar config on PR
run: |
mkdir -p ./prInfo
echo ${{ github.event.number }} > ./prInfo/PR
echo ${{ github.base_ref }} > ./prInfo/base_ref
echo ${{ github.head_ref }} > ./prInfo/head_ref
- uses: actions/upload-artifact@v3
with:
name: prInfo
path: prInfo/


kubernetes-integration-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
ref: ${{github.event.workflow_run.head_sha}}
# TODO remove locally building common-ui-test-library after new release of common-ui-test-library
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
cache: 'gradle'
- name: 'Clone common-ui-test-library to Maven Local repository'
run: |
git clone --branch 174 https://github.com/richard0202/intellij-common-ui-test-library.git ../common-ui-test-library
- uses: burrunan/gradle-cache-action@v1
name: Build common-ui-test-library
with:
build-root-directory: ../common-ui-test-library
arguments: publishToMavenLocal
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'gradle'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0
name: Start cluster
with:
version: v0.11.1
- name: Setup cluster
run: |
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.19.1/install.sh | bash -s v0.19.1
kubectl create -f https://operatorhub.io/install/service-binding-operator.yaml
kubectl create -f https://operatorhub.io/install/stable/cloud-native-postgresql.yaml
nb=0
echo -n "Waiting for operator to show up "
while [ "$nb" != "2" ]
do
echo -n "."
sleep 1
nb=`kubectl get pods -n operators --no-headers --ignore-not-found | grep Running | wc -l`
done
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Play integration tests
run: ./gradlew integrationTest --continue --no-daemon
#disbale integrationTests as they do not pass for now
#- name: Play integration UI tests
# run: |
# echo "${{ secrets.IDEA_KEY_PASSPHRASE }}" | gpg --decrypt --passphrase-fd 0 --pinentry-mode loopback --output idea_license_token/idea.key idea_license_token/idea.key.gpg
# export DISPLAY=:99.0
# Xvfb -ac :99 -screen 0 1920x1080x16 &
# sleep 10
# ./gradlew integrationUITest --info --continue
- name: Publish tests reports
if: always()
uses: scacap/action-surefire-report@4cbb611f23a9b5a030c73c2b32190a80983956ed #v1
with:
github_token: ${{secrets.GITHUB_TOKEN}}
report_paths: '${{github.workspace}}/build/test-results/**/TEST-*.xml'
commit: ${{github.event.workflow_run.head_sha}}
check_name: Integration Test Report
- uses: actions/upload-artifact@v3
if: always()
with:
name: kubernetes-integration-tests-reports
path: |
build/test-results/**/*.xml
build/jacoco/
2 changes: 1 addition & 1 deletion .github/workflows/publish_reports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
github_token: ${{secrets.GITHUB_TOKEN}}
report_paths: '${{github.workspace}}/*test-reports/**/TEST-*.xml'
commit: ${{github.event.workflow_run.head_sha}}
check_name: Aggregated Unit Test Report
check_name: Aggregated Test Report
6 changes: 3 additions & 3 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Sonar
on:
workflow_run:
workflows: [ "Play Integration Tests" ]
workflows: [ "Java CI with Gradle" ]
types:
- completed
jobs:
Expand Down Expand Up @@ -29,7 +29,7 @@ jobs:
run_id: ${{github.event.workflow_run.id}},
});
for (var artifact of artifacts.data.artifacts) {
if (artifact.name == 'kubernetes-integration-tests-reports' || artifact.name == 'prInfo') {
if (artifact.name == 'kubernetes-integration-tests-reports' || artifact.name == 'ubuntu-latest-test-reports' || artifact.name == 'prInfo') {
var zipfile = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -48,7 +48,7 @@ jobs:
}
- name: Unzip artifacts
run: |
find . -name '*.zip' -exec sh -c 'unzip -d "${1%.*}" "$1"' _ {} \;
find . -name '*.zip' -exec sh -c 'unzip -d "${{github.workspace}}/build" "$1"' _ {} \;
- name: Create coverage report
run: |
./gradlew jacocoTestReport
Expand Down

0 comments on commit 3d2f8c6

Please sign in to comment.