Skip to content

Commit 1dc05f9

Browse files
Update build-and-run-tests.yml
1 parent 985204b commit 1dc05f9

File tree

1 file changed

+13
-106
lines changed

1 file changed

+13
-106
lines changed

.github/workflows/build-and-run-tests.yml

Lines changed: 13 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -10,131 +10,40 @@ env:
1010
REGISTRY: ghcr.io
1111
IMAGE_NAME: utbot_java_cli
1212
DOCKERFILE_PATH: docker/Dockerfile_java_cli
13+
# Environment variable setting gradle options.
1314
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"
1415

1516
jobs:
16-
prepare-tests-matrix:
17-
runs-on: ubuntu-latest
18-
outputs:
19-
matrix: ${{ steps.set-matrix.outputs.matrix }}
20-
steps:
21-
- name: Checkout repository
22-
uses: actions/checkout@v3
23-
- id: set-matrix
24-
name: Read and print config from framework-tests-matrix.json
25-
run: |
26-
TASKS=$(echo $(cat .github/workflows/framework-tests-matrix.json))
27-
echo "::set-output name=matrix::$TASKS"
28-
echo $TASKS
29-
30-
31-
framework:
32-
needs: prepare-tests-matrix
33-
strategy:
34-
fail-fast: false
35-
matrix: ${{ fromJson(needs.prepare-tests-matrix.outputs.matrix) }}
36-
runs-on: ubuntu-20.04
37-
container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
38-
steps:
39-
- uses: actions/checkout@v3
40-
41-
- name: Check out ${{ github.event.inputs.commit-sha }} commit
42-
run: |
43-
git fetch
44-
git checkout ${{ github.event.inputs.commit-sha }}
45-
46-
- name: Run monitoring
47-
run: |
48-
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
49-
chmod +x ./scripts/monitoring.sh
50-
./scripts/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
51-
52-
- name: Run tests
53-
run: |
54-
gradle --no-daemon :utbot-framework:test ${{ matrix.project.TESTS_TO_RUN }}
55-
56-
- name: Upload logs
57-
if: ${{ always() }}
58-
uses: actions/upload-artifact@v3
59-
with:
60-
name: logs ${{ matrix.project.PART_NAME }}
61-
path: utbot-framework/logs/*
62-
63-
- name: Upload UTBot temp directory content
64-
if: ${{ always() }}
65-
uses: actions/upload-artifact@v3
66-
with:
67-
name: utbot_temp ${{ matrix.project.PART_NAME }}
68-
path: |
69-
/tmp/UTBot/generated*/*
70-
/tmp/UTBot/utbot-childprocess-errors/*
71-
72-
- name: Upload test report if tests have failed
73-
if: ${{ failure() }}
74-
uses: actions/upload-artifact@v3
75-
with:
76-
name: test_report ${{ matrix.project.PART_NAME }}
77-
path: utbot-framework/build/reports/tests/test/*
78-
79-
80-
project:
81-
# This job does not need to wait for 'prepare-tests-matrix' result.
82-
# This is a hack to force GitHub to allocate runners for framework project first (as the project build requires much time).
83-
needs: prepare-tests-matrix
84-
strategy:
85-
fail-fast: false
86-
matrix:
87-
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]
88-
runs-on: ubuntu-20.04
89-
container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
90-
steps:
91-
- uses: actions/checkout@v3
92-
93-
- name: Check out ${{ github.event.inputs.commit-sha }} commit
94-
run: |
95-
git fetch
96-
git checkout ${{ github.event.inputs.commit-sha }}
97-
98-
- name: Run monitoring
99-
run: |
100-
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
101-
chmod +x ./scripts/monitoring.sh
102-
./scripts/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
103-
104-
- name: Run tests
105-
run: |
106-
cd ${{ matrix.project }}
107-
gradle build --no-daemon
108-
109-
- name: Upload test report if tests have failed
110-
if: ${{ failure() }}
111-
uses: actions/upload-artifact@v3
112-
with:
113-
name: test_report ${{ matrix.project }}
114-
path: ${{ matrix.project }}/build/reports/tests/test/*
17+
build-and-run-tests:
18+
uses: ./.github/workflows/build-and-run-tests-from-branch.yml
11519

11620

11721
publish-cli-image:
118-
needs: framework
22+
needs: build-and-run-tests
11923
if: ${{ github.event_name == 'push' }}
12024
runs-on: ubuntu-20.04
12125
container: unittestbot/java-env:java11-zulu-jdk-fx-gradle7.4.2-kotlinc1.7.0
12226
steps:
27+
- name: Print environment variables
28+
run: printenv
29+
12330
- uses: actions/checkout@v3
12431

12532
- name: Set environment variables
12633
run: |
127-
echo COMMIT_SHORT_SHA="$(git rev-parse --short HEAD)" >> $GITHUB_ENV
34+
# "You can make an environment variable available to any subsequent steps in a workflow job by
35+
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
12836
echo VERSION="$(date +%Y).$(date +%-m)" >> $GITHUB_ENV
12937
13038
- name: Build UTBot Java CLI
13139
run: |
13240
cd utbot-cli
13341
gradle build --no-daemon -x test -PsemVer=${{ env.VERSION }}
134-
13542
- name: Set docker tag
13643
run:
137-
echo DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-${{ env.COMMIT_SHORT_SHA }}" >> $GITHUB_ENV
44+
# "You can make an environment variable available to any subsequent steps in a workflow job by
45+
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
46+
echo DOCKER_TAG="$(date +%Y).$(date +%-m).$(date +%-d)-${{ github.sha }}" >> $GITHUB_ENV
13847

13948
- name: Log in to the Container registry
14049
uses: docker/login-action@v2
@@ -153,7 +62,6 @@ jobs:
15362
key: ${{ runner.os }}-buildx-${{ github.sha }}
15463
restore-keys: |
15564
${{ runner.os }}-buildx-
156-
15765
- name: Docker meta
15866
id: meta
15967
uses: docker/metadata-action@v3
@@ -169,11 +77,10 @@ jobs:
16977
--cache-to "type=local,dest=/tmp/.buildx-cache-new" \
17078
--tag ${{ steps.meta.outputs.tags }} \
17179
--build-arg UTBOT_JAVA_CLI=utbot-cli/build/libs/utbot-cli-${{ env.VERSION }}.jar \
172-
--push .
80+
--push .
17381
# Temp fix
17482
# https://github.com/docker/build-push-action/issues/252
17583
# https://github.com/moby/buildkit/issues/1896
176-
17784
- name: Move cache
17885
run: |
17986
rm -rf /tmp/.buildx-cache

0 commit comments

Comments
 (0)