|
1 | 1 | name: "[M] UTBot Java: build and run tests"
|
2 | 2 |
|
3 | 3 | on:
|
4 |
| - workflow_dispatch |
5 |
| - |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + commit_sha: |
| 7 | + required: false |
| 8 | + type: string |
| 9 | + description: "Commit SHA (optional -- otherwise the last commit from the branch will be taken)" |
| 10 | + |
| 11 | + workflow_call: |
| 12 | + inputs: |
| 13 | + commit_sha: |
| 14 | + required: false |
| 15 | + type: string |
| 16 | + |
| 17 | +env: |
| 18 | + REGISTRY: ghcr.io |
| 19 | + IMAGE_NAME: utbot_java_cli |
| 20 | + DOCKERFILE_PATH: docker/Dockerfile_java_cli |
| 21 | + # Environment variable setting gradle options. |
| 22 | + GRADLE_OPTS: "-XX:MaxHeapSize=2048m -Dorg.gradle.jvmargs='-XX:MaxHeapSize=2048m -XX:MaxPermSize=512m -javaagent:/tmp/jmx-exporter.jar=12345:/tmp/jmx-exporter.yml -Dorg.gradle.daemon=false' -Dorg.gradle.daemon=false" |
| 23 | + |
6 | 24 | jobs:
|
7 |
| - build-and-run-tests: |
8 |
| - runs-on: ubuntu-20.04 |
| 25 | + prepare-tests-matrix: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + # Outputs are used for passing data to dependent jobs. |
| 28 | + outputs: |
| 29 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
9 | 30 | steps:
|
10 |
| - - uses: actions/checkout@v2 |
11 |
| - - uses: actions/setup-java@v2 |
12 |
| - with: |
13 |
| - java-version: '8' |
14 |
| - distribution: 'zulu' |
15 |
| - java-package: jdk+fx |
16 |
| - cache: gradle |
17 |
| - - uses: gradle/gradle-build-action@v2 |
18 |
| - with: |
19 |
| - gradle-version: 6.8 |
| 31 | + - name: Print environment variables |
| 32 | + run: printenv |
20 | 33 |
|
21 |
| - - name: Build and run tests in UTBot Java |
| 34 | + - name: Checkout repository |
| 35 | + uses: actions/checkout@v3 |
| 36 | + |
| 37 | + - name: Check out ${{ github.event.inputs.commit_sha }} commit |
| 38 | + if: github.event.inputs.commit_sha != '' |
| 39 | + run: | |
| 40 | + git fetch |
| 41 | + git checkout ${{ github.event.inputs.commit_sha }} |
| 42 | + - id: set-matrix |
| 43 | + name: Read and print config from framework-tests-matrix.json |
| 44 | + run: | |
| 45 | + TASKS=$(echo $(cat .github/workflows/framework-tests-matrix.json)) |
| 46 | + echo "::set-output name=matrix::$TASKS" |
| 47 | + echo $TASKS |
| 48 | + framework: |
| 49 | + # This job does not need to wait for 'prepare-tests-matrix' result. |
| 50 | + # GitHub allocates runners portionally. Framework tests are time consuming. That's why we want to force them |
| 51 | + # to start execution early. |
| 52 | + needs: prepare-tests-matrix |
| 53 | + # Using matrices let create multiple jobs runs based on the combinations of the variables from matrices. |
| 54 | + # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs |
| 55 | + strategy: |
| 56 | + # The option forces to execute all jobs even though some of them have failed. |
| 57 | + fail-fast: false |
| 58 | + matrix: ${{ fromJson(needs.prepare-tests-matrix.outputs.matrix) }} |
| 59 | + runs-on: ubuntu-20.04 |
| 60 | + container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0 |
| 61 | + steps: |
| 62 | + - name: Print environment variables |
| 63 | + run: printenv |
| 64 | + |
| 65 | + - name: Checkout repository |
| 66 | + uses: actions/checkout@v3 |
| 67 | + |
| 68 | + - name: Check out ${{ github.event.inputs.commit_sha }} commit |
| 69 | + if: github.event.inputs.commit_sha != '' |
22 | 70 | run: |
|
23 |
| - export KOTLIN_HOME="/usr" |
24 |
| - gradle clean build --no-daemon |
25 |
| - |
26 |
| - - name: Upload utbot-framework logs |
| 71 | + git fetch |
| 72 | + git checkout ${{ github.event.inputs.commit_sha }} |
| 73 | + - name: Run monitoring |
| 74 | + run: | |
| 75 | + echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"} |
| 76 | + chmod +x ./scripts/monitoring.sh |
| 77 | + ./scripts/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }} |
| 78 | + - name: Run tests |
| 79 | + run: | |
| 80 | + gradle --no-daemon :utbot-framework:test ${{ matrix.project.TESTS_TO_RUN }} |
| 81 | + - name: Upload logs |
27 | 82 | if: ${{ always() }}
|
28 |
| - uses: actions/upload-artifact@v2 |
| 83 | + uses: actions/upload-artifact@v3 |
29 | 84 | with:
|
30 |
| - name: utbot_framework_logs |
| 85 | + name: logs ${{ matrix.project.PART_NAME }} |
31 | 86 | path: utbot-framework/logs/*
|
32 |
| - |
33 |
| - - name: Upload utbot-framework tests report artifacts if tests have failed |
| 87 | + |
| 88 | + - name: Upload UTBot temp directory content |
| 89 | + if: ${{ always() }} |
| 90 | + uses: actions/upload-artifact@v3 |
| 91 | + with: |
| 92 | + name: utbot_temp ${{ matrix.project.PART_NAME }} |
| 93 | + path: | |
| 94 | + /tmp/UTBot/generated*/* |
| 95 | + /tmp/UTBot/utbot-childprocess-errors/* |
| 96 | + - name: Upload test report if tests have failed |
34 | 97 | if: ${{ failure() }}
|
35 |
| - uses: actions/upload-artifact@v2 |
| 98 | + uses: actions/upload-artifact@v3 |
36 | 99 | with:
|
37 |
| - name: utbot_framework_tests_report |
| 100 | + name: test_report ${{ matrix.project.PART_NAME }} |
38 | 101 | path: utbot-framework/build/reports/tests/test/*
|
39 |
| - |
40 |
| - - name: Upload utbot-intellij tests report artifacts if tests have failed |
| 102 | + |
| 103 | + |
| 104 | + project: |
| 105 | + needs: prepare-tests-matrix |
| 106 | + # Using matrices let create multiple jobs runs based on the combinations of the variables from matrices. |
| 107 | + # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs |
| 108 | + strategy: |
| 109 | + # The option forces to execute all jobs even though some of them have failed. |
| 110 | + fail-fast: false |
| 111 | + matrix: |
| 112 | + project: [utbot-api, utbot-cli, utbot-core, utbot-framework-api, utbot-fuzzers, utbot-gradle, utbot-instrumentation, utbot-instrumentation-tests, utbot-intellij, utbot-junit-contest, utbot-sample, utbot-summary, utbot-summary-tests] |
| 113 | + runs-on: ubuntu-20.04 |
| 114 | + container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0 |
| 115 | + steps: |
| 116 | + - name: Print environment variables |
| 117 | + run: printenv |
| 118 | + |
| 119 | + - name: Checkout repository |
| 120 | + uses: actions/checkout@v3 |
| 121 | + |
| 122 | + - name: Check out ${{ github.event.inputs.commit_sha }} commit |
| 123 | + if: github.event.inputs.commit_sha != '' |
| 124 | + run: | |
| 125 | + git fetch |
| 126 | + git checkout ${{ github.event.inputs.commit_sha }} |
| 127 | + - uses: actions/checkout@v3 |
| 128 | + with: |
| 129 | + ref: ${{ env.COMMIT_SHA }} |
| 130 | + |
| 131 | + - name: Run monitoring |
| 132 | + run: | |
| 133 | + echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"} |
| 134 | + chmod +x ./scripts/monitoring.sh |
| 135 | + ./scripts/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }} |
| 136 | + - name: Run tests |
| 137 | + run: | |
| 138 | + cd ${{ matrix.project }} |
| 139 | + gradle build --no-daemon |
| 140 | + - name: Upload test report if tests have failed |
41 | 141 | if: ${{ failure() }}
|
42 |
| - uses: actions/upload-artifact@v2 |
| 142 | + uses: actions/upload-artifact@v3 |
43 | 143 | with:
|
44 |
| - name: utbot_intellij_tests_report |
45 |
| - path: utbot-intellij/build/reports/tests/test/* |
| 144 | + name: test_report ${{ matrix.project }} |
| 145 | + path: ${{ matrix.project }}/build/reports/tests/test/* |
0 commit comments