Improve finding tests (1) (#1420)

This commit is contained in:
erabii
2023-08-30 17:06:16 +03:00
committed by GitHub
parent 87ffd673c7
commit 078fba15b5
18 changed files with 146 additions and 45 deletions

View File

@@ -3,14 +3,26 @@ description: maven-build-with-dry-run-for-tests
runs:
using: "composite"
steps:
- name: maven-build-with-dry-run-for-tests
- name: run 'package' on the project
shell: bash
run: |
# find all the tests that are supposed to be run, but don't actually run them.
# this is achieved via: 'spring.cloud.k8s.skip.tests=true' in DisabledTestsCondition
./mvnw test -B -Dskip.build.image=true -Dspring.cloud.k8s.skip.tests=true \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=error \
-T 1C -q > /tmp/tests.txt
./mvnw install -B \
-Dskip.build.image=true \
-DskipTests -DskipITs \
-T 1C -q
- name: find all classpath entries
shell: bash
run: |
./mvnw -q exec:exec -Dexec.classpathScope="test" -Dexec.executable="echo" -Dexec.args="%classpath" | tr : "\n" > /tmp/deps.txt
- name: find all tests
shell: bash
run: |
cd spring-cloud-kubernetes-test-support
.././mvnw -q exec:java -Dexec.mainClass="org.springframework.cloud.kubernetes.tests.discovery.TestsDiscovery" > /tmp/tests.txt
cd ..
- name: show result
if: always()

View File

@@ -8,8 +8,8 @@ runs:
uses: actions/cache/restore@v3
with:
path: /tmp/sorted.txt
key: ${{ runner.os }}-spring-cloud-kubernetes-existing-test-times-cache-${{ github.run_id }}
restore-keys: ${{ runner.os }}-spring-cloud-kubernetes-existing-test-times-cache-
key: ${{ runner.os }}-spring-cloud-k8s-existing-test-times-cache-${{ github.run_id }}
restore-keys: ${{ runner.os }}-spring-cloud-k8s-existing-test-times-cache-
- name: show cached test times
shell: bash
@@ -138,7 +138,7 @@ runs:
# the previous cache will contain more tests then we currently have, so some
# matrix instances will have no tests to run
if [[ "$sum" -eq "0" ]]; then
echo "no tests to run in current index, most probably this PR removed some tests"
echo "no tests (with known times) to run in current index"
tests_to_run_in_current_index='none'
fi

View File

@@ -47,7 +47,7 @@ runs:
# save with the current run_id, but restore it without it. This means two things:
# 1) if we re-run, cache will be available
# 2) if there is a new run, we restore as '${{ runner.os }}-spring-cloud-kubernetes-existing-test-times-cache-'
# 2) if there is a new run, we restore as '${{ runner.os }}-spring-cloud-k8s-existing-test-times-cache-'
# meaning there could be many of them already present and this is not an exact match
# github in this case will pick up the latest one, exactly what we want.
- name: save test times in cache
@@ -55,4 +55,4 @@ runs:
if: env.BASE_BRANCH != '2.1.x'
with:
path: /tmp/sorted.txt
key: ${{ runner.os }}-spring-cloud-kubernetes-existing-test-times-cache-${{ github.run_id }}
key: ${{ runner.os }}-spring-cloud-k8s-existing-test-times-cache-${{ github.run_id }}

View File

@@ -67,8 +67,8 @@ jobs:
uses: actions/cache/restore@v3
with:
path: /tmp/sorted.txt
key: ${{ runner.os }}-spring-cloud-kubernetes-existing-test-times-cache-${{ github.run_id }}
restore-keys: ${{ runner.os }}-spring-cloud-kubernetes-existing-test-times-cache-
key: ${{ runner.os }}-spring-cloud-k8s-existing-test-times-cache-${{ github.run_id }}
restore-keys: ${{ runner.os }}-spring-cloud-k8s-existing-test-times-cache-
- name: check test times cache exists
id: check_files