Skip to content

Commit 593e97e

Browse files
authored
[ML][6.5] Add support for PR CI builds (elastic#234)
The CI scripts will now behave differently if triggered from a PR build: 1. The code style will be checked first and style violations will cause the PR check to fail 2. The artifacts will only be uploaded to S3 for non-PR builds PR builds are detected by checking whether a PR_AUTHOR environment variable exists. Backport of elastic#233.
1 parent 395f57f commit 593e97e

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

dev-tools/ci

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
# you may not use this file except in compliance with the Elastic License.
66
#
77

8-
# The non-Windows part of ML C++ CI:
8+
# The non-Windows part of ML C++ CI does the following:
99
#
10-
# 1. Build and unit test the Linux version of the C++
11-
# 2. Build the macOS version of the C++
12-
# 3. Upload the builds to the artifacts directory on S3 that
13-
# subsequent Java builds will download the C++ components from
10+
# 1. If this is a PR build, check the code style
11+
# 2. Build and unit test the Linux version of the C++
12+
# 3. Build the macOS version of the C++
13+
# 4. If this is not a PR build, upload the builds to the artifacts directory on
14+
# S3 that subsequent Java builds will download the C++ components from
1415
#
15-
# The builds run in Docker containers that ensure OS dependencies
16+
# The steps run in Docker containers that ensure OS dependencies
1617
# are appropriate given the support matrix.
1718
#
1819
# The macOS build cannot be unit tested as it is cross-compiled.
@@ -30,13 +31,20 @@ fi
3031
# Remove any old builds
3132
rm -rf ../builds
3233

34+
# If this is a PR build then fail fast on style checks
35+
if [ -n "$PR_AUTHOR" ] ; then
36+
./docker_check_style.sh
37+
fi
38+
3339
# Build and test Linux
3440
./docker_test.sh linux
3541

3642
# Build macOS
3743
./docker_build.sh macosx
3844

39-
# Upload
40-
cd ..
41-
./gradlew --info -b upload.gradle upload
45+
# If this isn't a PR build then upload the artifacts
46+
if [ -z "$PR_AUTHOR" ] ; then
47+
cd ..
48+
./gradlew --info -b upload.gradle upload
49+
fi
4250

dev-tools/ci.bat

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ rem or more contributor license agreements. Licensed under the Elastic License;
55
rem you may not use this file except in compliance with the Elastic License.
66
rem
77

8-
rem The Windows part of ML C++ CI:
8+
rem The Windows part of ML C++ CI does the following:
99
rem
1010
rem 1. Build and unit test the Windows version of the C++
11-
rem 2. Upload the build to the artifacts directory on S3 that
12-
rem subsequent Java builds will download the C++ components from
11+
rem 2. If this is not a PR build, upload the build to the artifacts directory on
12+
rem S3 that subsequent Java builds will download the C++ components from
1313

1414
setlocal enableextensions
1515

@@ -24,8 +24,8 @@ rem Run the build and unit tests
2424
set ML_KEEP_GOING=1
2525
call .\gradlew.bat --info clean buildZip buildZipSymbols check || exit /b %ERRORLEVEL%
2626

27-
rem Upload the artifacts to S3
28-
call .\gradlew.bat --info -b upload.gradle upload || exit /b %ERRORLEVEL%
27+
rem If this isn't a PR build then upload the artifacts
28+
if not defined PR_AUTHOR call .\gradlew.bat --info -b upload.gradle upload || exit /b %ERRORLEVEL%
2929

3030
endlocal
3131

0 commit comments

Comments
 (0)