Skip to content

Commit

Permalink
Make CI only build/test modules with any changes
Browse files Browse the repository at this point in the history
The gitflow-incremental-builder (GIB) Maven extension allows to
only build modules that contain any changes. It compares the current git branch
with the merge base and selects modules with any modified files.

All (upstream) dependencies of impacted modules are built, but without
running tests. All dependant (downstream) modules of impacted modules
are also build and tested. If there are changes in the root module,
everything would be built.

Note this is only enabled in the ci profile.

This does not affect product tests, which would always run with full coverage.
  • Loading branch information
nineinchnick authored and hashhar committed Feb 28, 2022
1 parent 60f81a9 commit aa95c13
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .github/bin/git-fetch-base-ref.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -euo pipefail

if [ -z "${GITHUB_BASE_REF:-}" ] || [ "$GITHUB_BASE_REF" == master ]; then
echo >&2 "GITHUB_BASE_REF is not set or is master, not fetching it"
exit 0
fi

git fetch --no-tags --prune origin "$GITHUB_BASE_REF"
37 changes: 32 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ env:
# maven.wagon.rto is in millis, defaults to 30m
MAVEN_OPTS: "-Xmx512M -XX:+ExitOnOutOfMemoryError -Dmaven.wagon.rto=60000"
MAVEN_INSTALL_OPTS: "-Xmx2G -XX:+ExitOnOutOfMemoryError -Dmaven.wagon.rto=60000"
MAVEN_FAST_INSTALL: "-B --strict-checksums -V --quiet -T C1 -DskipTests -Dair.check.skip-all"
MAVEN_TEST: "-B --strict-checksums -Dair.check.skip-all --fail-at-end"
MAVEN_FAST_INSTALL: "-B --strict-checksums -V --quiet -T C1 -DskipTests -Dmaven.source.skip=true -Dair.check.skip-all -P gib -Dgib.referenceBranch=refs/remotes/origin/${{ github.event.pull_request.base.ref }}"
MAVEN_TEST: "-B --strict-checksums -Dmaven.source.skip=true -Dair.check.skip-all --fail-at-end -P gib -Dgib.referenceBranch=refs/remotes/origin/${{ github.event.pull_request.base.ref }}"
RETRY: .github/bin/retry
# Testcontainers kills image pulls if they don't make progress for > 30s and retries for 2m before failing. This means
# that if an image doesn't download all it's layers within ~2m then any other concurrent pull will be killed because
Expand Down Expand Up @@ -74,6 +74,10 @@ jobs:
timeout-minutes: 45
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB
- name: Fetch base ref to find merge-base for GIB
run: .github/bin/git-fetch-base-ref.sh
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
Expand All @@ -90,9 +94,9 @@ jobs:
run: |
export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}"
# Run Error Prone on one module with a retry to ensure all runtime dependencies are fetched
$RETRY $MAVEN ${MAVEN_TEST} -T C1 clean test-compile -P errorprone-compiler -pl ':trino-spi'
$RETRY $MAVEN ${MAVEN_TEST} -T C1 clean test-compile -P gib,errorprone-compiler -pl ':trino-spi'
# The main Error Prone run
$MAVEN ${MAVEN_TEST} -T C1 clean test-compile -P errorprone-compiler \
$MAVEN ${MAVEN_TEST} -T C1 clean test-compile -P gib,errorprone-compiler \
-pl '!:trino-docs,!:trino-server,!:trino-server-rpm'
web-ui-checks:
Expand All @@ -110,6 +114,8 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # checkout tags so version in Manifest is set properly
- name: Fetch base ref to find merge-base for GIB
run: .github/bin/git-fetch-base-ref.sh
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
Expand Down Expand Up @@ -161,6 +167,10 @@ jobs:
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB
- name: Fetch base ref to find merge-base for GIB
run: .github/bin/git-fetch-base-ref.sh
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
Expand Down Expand Up @@ -274,6 +284,10 @@ jobs:
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB
- name: Fetch base ref to find merge-base for GIB
run: .github/bin/git-fetch-base-ref.sh
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
Expand Down Expand Up @@ -369,6 +383,10 @@ jobs:
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB
- name: Fetch base ref to find merge-base for GIB
run: .github/bin/git-fetch-base-ref.sh
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
Expand Down Expand Up @@ -417,6 +435,10 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB
- name: Fetch base ref to find merge-base for GIB
run: .github/bin/git-fetch-base-ref.sh
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
Expand Down Expand Up @@ -465,6 +487,10 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB
- name: Fetch base ref to find merge-base for GIB
run: .github/bin/git-fetch-base-ref.sh
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
Expand Down Expand Up @@ -613,7 +639,8 @@ jobs:
- name: Maven Install
run: |
export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}"
$RETRY $MAVEN install ${MAVEN_FAST_INSTALL} -pl '!:trino-docs,!:trino-server-rpm'
# GIB needs to be explicitly disabled, because the gib profile enables it, but the trino-server module requires all of its dependencies to be built
$RETRY $MAVEN install ${MAVEN_FAST_INSTALL} -Dgib.disable -pl '!:trino-docs,!:trino-server-rpm'
- name: Free Disk Space
run: |
docker image prune -af
Expand Down
34 changes: 34 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1863,5 +1863,39 @@
</plugins>
</build>
</profile>
<profile>
<id>gib</id>
<properties>
<!-- the *local* master, not refs/remotes/... -->
<gib.referenceBranch>master</gib.referenceBranch>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.vackosar.gitflowincrementalbuilder</groupId>
<artifactId>gitflow-incremental-builder</artifactId>
<version>3.15.0</version>
<extensions>true</extensions>
<configuration>
<disableIfBranchMatches>master</disableIfBranchMatches>
<compareToMergeBase>true</compareToMergeBase>
<uncommitted>true</uncommitted>
<untracked>true</untracked>
<buildDownstream>true</buildDownstream>
<buildUpstream>true</buildUpstream>
<buildUpstreamMode>impacted</buildUpstreamMode>
<!-- Skip tests and checks for upstream modules since they have not been modified but are still required to be built -->
<skipTestsForUpstreamModules>true</skipTestsForUpstreamModules>
<argsForUpstreamModules>-Dmaven.source.skip=true -Dair.check.skip-all</argsForUpstreamModules>
<!-- Any modules selected with -pl will be built fully (with tests etc.) if the selected module itself is changed
or one of its (non-selected) upstream modules -->
<disableSelectedProjectsHandling>true</disableSelectedProjectsHandling>
<failOnMissingGitDir>true</failOnMissingGitDir>
<failOnError>true</failOnError>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit aa95c13

Please sign in to comment.