diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 71ed757..1ac4db1 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,5 +1,22 @@ name: MISP2 tests -on: [pull_request] +on: + push: + branches: + - develop + paths: + - 'web-app/**' + - '.github/**' + - 'orbeon-war/**' + - 'packages/**' + - 'utils/**' + pull_request: + types: [opened, synchronize, reopened] + paths: + - 'web-app/**' + - '.github/**' + - 'orbeon-war/**' + - 'packages/**' + - 'utils/**' jobs: run-test: runs-on: ubuntu-22.04 @@ -14,13 +31,56 @@ jobs: distribution: 'temurin' - name: Set up Gradle uses: gradle/gradle-build-action@v2 + with: + cache-read-only: ${{ github.ref != 'refs/heads/develop' }} + gradle-home-cache-cleanup: true - name: Run test run: ./gradlew test - - name: Store upload test artifacts + - name: Test report + env: + NODE_OPTIONS: '--max-old-space-size=6144' + uses: dorny/test-reporter@v1 + if: success() || failure() + with: + name: Unit and integration tests + path: web-app/build/test-results/**/TEST-*.xml + reporter: java-junit + list-suites: 'failed' + list-tests: 'failed' + - name: Store test screenshots uses: actions/upload-artifact@v3 if: failure() with: name: Test results - path: | - /home/runner/work/misp2/misp2/web-app/build/reports/tests/test/index.html - /home/runner/work/misp2/misp2/web-app/build/it-screenshots/ + path: /home/runner/work/misp2/misp2/web-app/build/it-screenshots/ + sonar-analysis: + name: Analyse source + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + submodules: 'true' + # Bit of a hacky solution so that the CLI would run (exits with code 1 if build.gradle is found) + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'temurin' + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 + with: + cache-read-only: ${{ github.ref != 'refs/heads/develop' }} + gradle-home-cache-cleanup: true + - name: Run build + run: ./gradlew build -x test + - name: Remove build.gradle so that we can use the CLI + run: | + rm -f build.gradle + rm -f web-app/build.gradle + # Running CLI because JAVA 8 is not supported by the plugin anymore + - name: Sonar analysis + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..e05a4c4 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,5 @@ +sonar.projectKey=nordic-institute_misp2-test +sonar.organization=nordic-institute + +sonar.sources=web-app/src +sonar.java.binaries=web-app/build