Skip to content

Commit aa95c13

Browse files
Jan Washashhar
authored andcommitted
Make CI only build/test modules with any changes
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.
1 parent 60f81a9 commit aa95c13

File tree

3 files changed

+76
-5
lines changed

3 files changed

+76
-5
lines changed

.github/bin/git-fetch-base-ref.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
if [ -z "${GITHUB_BASE_REF:-}" ] || [ "$GITHUB_BASE_REF" == master ]; then
6+
echo >&2 "GITHUB_BASE_REF is not set or is master, not fetching it"
7+
exit 0
8+
fi
9+
10+
git fetch --no-tags --prune origin "$GITHUB_BASE_REF"

.github/workflows/ci.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ env:
1616
# maven.wagon.rto is in millis, defaults to 30m
1717
MAVEN_OPTS: "-Xmx512M -XX:+ExitOnOutOfMemoryError -Dmaven.wagon.rto=60000"
1818
MAVEN_INSTALL_OPTS: "-Xmx2G -XX:+ExitOnOutOfMemoryError -Dmaven.wagon.rto=60000"
19-
MAVEN_FAST_INSTALL: "-B --strict-checksums -V --quiet -T C1 -DskipTests -Dair.check.skip-all"
20-
MAVEN_TEST: "-B --strict-checksums -Dair.check.skip-all --fail-at-end"
19+
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 }}"
20+
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 }}"
2121
RETRY: .github/bin/retry
2222
# Testcontainers kills image pulls if they don't make progress for > 30s and retries for 2m before failing. This means
2323
# that if an image doesn't download all it's layers within ~2m then any other concurrent pull will be killed because
@@ -74,6 +74,10 @@ jobs:
7474
timeout-minutes: 45
7575
steps:
7676
- uses: actions/checkout@v2
77+
with:
78+
fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB
79+
- name: Fetch base ref to find merge-base for GIB
80+
run: .github/bin/git-fetch-base-ref.sh
7781
- uses: actions/setup-java@v2
7882
with:
7983
distribution: 'zulu'
@@ -90,9 +94,9 @@ jobs:
9094
run: |
9195
export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}"
9296
# Run Error Prone on one module with a retry to ensure all runtime dependencies are fetched
93-
$RETRY $MAVEN ${MAVEN_TEST} -T C1 clean test-compile -P errorprone-compiler -pl ':trino-spi'
97+
$RETRY $MAVEN ${MAVEN_TEST} -T C1 clean test-compile -P gib,errorprone-compiler -pl ':trino-spi'
9498
# The main Error Prone run
95-
$MAVEN ${MAVEN_TEST} -T C1 clean test-compile -P errorprone-compiler \
99+
$MAVEN ${MAVEN_TEST} -T C1 clean test-compile -P gib,errorprone-compiler \
96100
-pl '!:trino-docs,!:trino-server,!:trino-server-rpm'
97101
98102
web-ui-checks:
@@ -110,6 +114,8 @@ jobs:
110114
- uses: actions/checkout@v2
111115
with:
112116
fetch-depth: 0 # checkout tags so version in Manifest is set properly
117+
- name: Fetch base ref to find merge-base for GIB
118+
run: .github/bin/git-fetch-base-ref.sh
113119
- uses: actions/setup-java@v2
114120
with:
115121
distribution: 'zulu'
@@ -161,6 +167,10 @@ jobs:
161167
timeout-minutes: 60
162168
steps:
163169
- uses: actions/checkout@v2
170+
with:
171+
fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB
172+
- name: Fetch base ref to find merge-base for GIB
173+
run: .github/bin/git-fetch-base-ref.sh
164174
- uses: actions/setup-java@v2
165175
with:
166176
distribution: 'zulu'
@@ -274,6 +284,10 @@ jobs:
274284
timeout-minutes: 60
275285
steps:
276286
- uses: actions/checkout@v2
287+
with:
288+
fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB
289+
- name: Fetch base ref to find merge-base for GIB
290+
run: .github/bin/git-fetch-base-ref.sh
277291
- uses: actions/setup-java@v2
278292
with:
279293
distribution: 'zulu'
@@ -369,6 +383,10 @@ jobs:
369383
timeout-minutes: 60
370384
steps:
371385
- uses: actions/checkout@v2
386+
with:
387+
fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB
388+
- name: Fetch base ref to find merge-base for GIB
389+
run: .github/bin/git-fetch-base-ref.sh
372390
- uses: actions/setup-java@v2
373391
with:
374392
distribution: 'zulu'
@@ -417,6 +435,10 @@ jobs:
417435
timeout-minutes: 30
418436
steps:
419437
- uses: actions/checkout@v2
438+
with:
439+
fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB
440+
- name: Fetch base ref to find merge-base for GIB
441+
run: .github/bin/git-fetch-base-ref.sh
420442
- uses: actions/setup-java@v2
421443
with:
422444
distribution: 'zulu'
@@ -465,6 +487,10 @@ jobs:
465487
timeout-minutes: 30
466488
steps:
467489
- uses: actions/checkout@v2
490+
with:
491+
fetch-depth: 0 # checkout all commits to be able to determine merge base for GIB
492+
- name: Fetch base ref to find merge-base for GIB
493+
run: .github/bin/git-fetch-base-ref.sh
468494
- uses: actions/setup-java@v2
469495
with:
470496
distribution: 'zulu'
@@ -613,7 +639,8 @@ jobs:
613639
- name: Maven Install
614640
run: |
615641
export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}"
616-
$RETRY $MAVEN install ${MAVEN_FAST_INSTALL} -pl '!:trino-docs,!:trino-server-rpm'
642+
# 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
643+
$RETRY $MAVEN install ${MAVEN_FAST_INSTALL} -Dgib.disable -pl '!:trino-docs,!:trino-server-rpm'
617644
- name: Free Disk Space
618645
run: |
619646
docker image prune -af

pom.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,5 +1863,39 @@
18631863
</plugins>
18641864
</build>
18651865
</profile>
1866+
<profile>
1867+
<id>gib</id>
1868+
<properties>
1869+
<!-- the *local* master, not refs/remotes/... -->
1870+
<gib.referenceBranch>master</gib.referenceBranch>
1871+
</properties>
1872+
<build>
1873+
<plugins>
1874+
<plugin>
1875+
<groupId>com.vackosar.gitflowincrementalbuilder</groupId>
1876+
<artifactId>gitflow-incremental-builder</artifactId>
1877+
<version>3.15.0</version>
1878+
<extensions>true</extensions>
1879+
<configuration>
1880+
<disableIfBranchMatches>master</disableIfBranchMatches>
1881+
<compareToMergeBase>true</compareToMergeBase>
1882+
<uncommitted>true</uncommitted>
1883+
<untracked>true</untracked>
1884+
<buildDownstream>true</buildDownstream>
1885+
<buildUpstream>true</buildUpstream>
1886+
<buildUpstreamMode>impacted</buildUpstreamMode>
1887+
<!-- Skip tests and checks for upstream modules since they have not been modified but are still required to be built -->
1888+
<skipTestsForUpstreamModules>true</skipTestsForUpstreamModules>
1889+
<argsForUpstreamModules>-Dmaven.source.skip=true -Dair.check.skip-all</argsForUpstreamModules>
1890+
<!-- Any modules selected with -pl will be built fully (with tests etc.) if the selected module itself is changed
1891+
or one of its (non-selected) upstream modules -->
1892+
<disableSelectedProjectsHandling>true</disableSelectedProjectsHandling>
1893+
<failOnMissingGitDir>true</failOnMissingGitDir>
1894+
<failOnError>true</failOnError>
1895+
</configuration>
1896+
</plugin>
1897+
</plugins>
1898+
</build>
1899+
</profile>
18661900
</profiles>
18671901
</project>

0 commit comments

Comments
 (0)