Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jenkins/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
all check:
shellcheck *.sh
8 changes: 5 additions & 3 deletions jenkins/build-api-diff.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/bin/bash -e

cd "$(dirname "${BASH_SOURCE[0]}")/.."
WORKSPACE=$(pwd)

report_error ()
{
printf "🔥 [Failed to create API Diff]($BUILD_URL/console) 🔥\\n" >> $WORKSPACE/jenkins/pr-comments.md
printf "🔥 [Failed to create API Diff](%s/console) 🔥\\n" "$BUILD_URL" >> "$WORKSPACE/jenkins/pr-comments.md"
}
trap report_error ERR

cd $WORKSPACE
export BUILD_REVISION=jenkins
make -j8 -C tools/apidiff jenkins-api-diff

printf "✅ [API Diff (from stable)]($BUILD_URL/API_20diff_20_28from_20stable_29)\\n" >> $WORKSPACE/jenkins/pr-comments.md
printf "✅ [API Diff (from stable)](%s/API_20diff_20_28from_20stable_29)\\n" "$BUILD_URL" >> "$WORKSPACE/jenkins/pr-comments.md"
20 changes: 12 additions & 8 deletions jenkins/build.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
#!/bin/bash -e

cd "$(dirname "${BASH_SOURCE[0]}")/.."
WORKSPACE=$(pwd)

report_error ()
{
printf "🔥 [Build failed]($BUILD_URL/console) 🔥\\n" >> $WORKSPACE/jenkins/pr-comments.md
printf "🔥 [Build failed](%s/console) 🔥\\n" "$BUILD_URL" >> "$WORKSPACE/jenkins/pr-comments.md"
}
trap report_error ERR

ls -la $WORKSPACE/jenkins
ls -la "$WORKSPACE/jenkins"
echo "$WORKSPACE/jenkins/pr-comments.md:"
cat $WORKSPACE/jenkins/pr-comments.md
cat "$WORKSPACE/jenkins/pr-comments.md"

cd $WORKSPACE
export BUILD_REVISION=jenkins

ENABLE_DEVICE_BUILD=

if test -z $ghprbPullId; then
# SC2154: ghprbPullId is referenced but not assigned.
# shellcheck disable=SC2154
if test -z "$ghprbPullId"; then
echo "Could not find the environment variable ghprbPullId, so won't check if we're doing a device build."
else
echo "Listing modified files for pull request #$ghprbPullId..."
if git diff-tree --no-commit-id --name-only -r "origin/pr/$ghprbPullId/merge^..origin/pr/$ghprbPullId/merge" > .tmp-files; then
echo "Modified files found":
cat .tmp-files | sed 's/^/ /' || true
sed 's/^/ /' .tmp-files || true
if grep 'external/mono' .tmp-files > /dev/null; then
echo "Enabling device build because mono was bumped."
elif grep 'external/llvm' .tmp-files > /dev/null; then
Expand All @@ -32,7 +36,7 @@ else
fi
rm -f .tmp-files

if test -z $ENABLE_DEVICE_BUILD; then
if test -z "$ENABLE_DEVICE_BUILD"; then
if ./jenkins/fetch-pr-labels.sh --check=enable-device-build; then
ENABLE_DEVICE_BUILD=1
echo "Enabling device build because the label 'enable-device-build' was found."
Expand All @@ -50,4 +54,4 @@ fi

time make world

printf "✅ [Build succeeded]($BUILD_URL/console)\\n" >> $WORKSPACE/jenkins/pr-comments.md
printf "✅ [Build succeeded](%s/console)\\n" "$BUILD_URL" >> "$WORKSPACE/jenkins/pr-comments.md"
24 changes: 14 additions & 10 deletions jenkins/compare.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
#!/bin/bash -e

cd "$(dirname "${BASH_SOURCE[0]}")/.."
WORKSPACE=$(pwd)

report_error ()
{
printf "🔥 [Failed to compare API and create generator diff]($BUILD_URL/console) 🔥\\n" >> $WORKSPACE/jenkins/pr-comments.md
touch $WORKSPACE/jenkins/failure-stamp
printf "🔥 [Failed to compare API and create generator diff](%s/console) 🔥\\n" "$BUILD_URL" >> "$WORKSPACE/jenkins/pr-comments.md"
touch "$WORKSPACE/jenkins/failure-stamp"
exit 0
}
trap report_error ERR

cd $WORKSPACE

if ./jenkins/fetch-pr-labels.sh --check=skip-api-comparison; then
printf "❎ Skipped API comparison because the PR has the label 'skip-api-comparison'\\n" >> $WORKSPACE/jenkins/pr-comments.md
printf "❎ Skipped API comparison because the PR has the label 'skip-api-comparison'\\n" >> "$WORKSPACE/jenkins/pr-comments.md"
exit 0
fi

BASE=origin/pr/$ghprbPullId/merge
if ! git rev-parse $BASE >/dev/null 2>&1; then
# SC2154: ghprbPullId is referenced but not assigned.
# shellcheck disable=SC2154
BASE="origin/pr/$ghprbPullId/merge"
if ! git rev-parse "$BASE" >/dev/null 2>&1; then
echo "Can't compare API and create generator diff because the pull request has conflicts that must be resolved first (the branch '$BASE' doesn't exist)."
printf "🔥 [Failed to compare API and create generator diff because the pull request has conflicts that must be resolved first]($BUILD_URL/console) 🔥\\n" >> $WORKSPACE/jenkins/pr-comments.md
printf "🔥 [Failed to compare API and create generator diff because the pull request has conflicts that must be resolved first](%s/console) 🔥\\n" "$BUILD_URL" >> "$WORKSPACE/jenkins/pr-comments.md"
exit 0
fi

./tools/compare-commits.sh --base=$BASE^1
./tools/compare-commits.sh --base="$BASE^1"

mkdir -p jenkins-results/apicomparison

cp -R tools/comparison/apidiff/diff jenkins-results/apicomparison/
cp tools/comparison/apidiff/*.html jenkins-results/apicomparison/
cp -R tools/comparison/generator-diff jenkins-results/generator-diff

printf "✅ [API Diff (from PR only)]($BUILD_URL/API_20diff_20_28PR_20only_29)\\n" >> $WORKSPACE/jenkins/pr-comments.md
printf "✅ [Generator Diff]($BUILD_URL/Generator_20Diff)\\n" >> $WORKSPACE/jenkins/pr-comments.md
printf "✅ [API Diff (from PR only)](%s/API_20diff_20_28PR_20only_29)\\n" "$BUILD_URL" >> "$WORKSPACE/jenkins/pr-comments.md"
printf "✅ [Generator Diff](%s/Generator_20Diff)\\n" "$BUILD_URL" >> "$WORKSPACE/jenkins/pr-comments.md"
2 changes: 2 additions & 0 deletions jenkins/fetch-pr-labels.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash -e

# SC2154: ghprbPullId is referenced but not assigned.
# shellcheck disable=SC2154
if test -z "$ghprbPullId"; then
echo "Could not find the environment variable ghprbPullId, so it's not possible to fetch the labels for any pull request."
exit 1
Expand Down
8 changes: 5 additions & 3 deletions jenkins/provision-deps.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/bin/bash -e

cd "$(dirname "${BASH_SOURCE[0]}")/.."
WORKSPACE=$(pwd)

report_error ()
{
echo "🔥 [Provisioning failed]($BUILD_URL/console) 🔥" >> $WORKSPACE/jenkins/pr-comments.md
echo "🔥 [Provisioning failed]($BUILD_URL/console) 🔥" >> "$WORKSPACE/jenkins/pr-comments.md"
}
trap report_error ERR

cd $WORKSPACE
./system-dependencies.sh --provision-all

echo "✅ [Provisioning succeeded]($BUILD_URL/console)" >> $WORKSPACE/jenkins/pr-comments.md
echo "✅ [Provisioning succeeded]($BUILD_URL/console)" >> "$WORKSPACE/jenkins/pr-comments.md"
26 changes: 15 additions & 11 deletions jenkins/run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
#!/bin/bash -e

cd "$(dirname "${BASH_SOURCE[0]}")/.."
WORKSPACE=$(pwd)

report_error ()
{
printf "🔥 [Test run failed]($BUILD_URL/Test_20Report/) 🔥\\n" >> $WORKSPACE/jenkins/pr-comments.md
printf "🔥 [Test run failed](%s/Test_20Report) 🔥\\n" "$BUILD_URL" >> "$WORKSPACE/jenkins/pr-comments.md"

if test -f $WORKSPACE/tests/TestSummary.md; then
printf "\\n" >> $WORKSPACE/jenkins/pr-comments.md
cat $WORKSPACE/tests/TestSummary.md >> $WORKSPACE/jenkins/pr-comments.md
if test -f "$WORKSPACE/tests/TestSummary.md"; then
printf "\\n" >> "$WORKSPACE/jenkins/pr-comments.md"
cat "$WORKSPACE/tests/TestSummary.md" >> "$WORKSPACE/jenkins/pr-comments.md"
fi

touch $WORKSPACE/jenkins/failure-stamp
touch "$WORKSPACE/jenkins/failure-stamp"
}
trap report_error ERR

export BUILD_REVISION=jenkins
cd $WORKSPACE

# Unlock
security default-keychain -s builder.keychain
security list-keychains -s builder.keychain
echo "Unlock keychain"
security unlock-keychain -p `cat ~/.config/keychain`
security unlock-keychain -p "$(cat ~/.config/"$KEYCHAIN"-keychain)"
echo "Increase keychain unlock timeout"
security set-keychain-settings -lut 7200

# Prevent dialogs from asking for permissions.
# http://stackoverflow.com/a/40039594/183422
security set-key-partition-list -S apple-tool:,apple: -s -k `cat ~/.config/keychain` builder.keychain
# Discard output since there can be a *lot* of it.
security set-key-partition-list -S apple-tool:,apple: -s -k "$(cat ~/.config/keychain)" builder.keychain >/dev/null 2>&1

# clean mono keypairs (used in tests)
rm -rf ~/.config/.mono/keypairs/

# Run tests
make -C tests jenkins

printf "✅ [Test run succeeded]($BUILD_URL/Test_20Report/)\\n" >> $WORKSPACE/jenkins/pr-comments.md
printf "✅ [Test run succeeded](%s/Test_20Report/)\\n" "$BUILD_URL" >> "$WORKSPACE/jenkins/pr-comments.md"

if test -f $WORKSPACE/jenkins/failure-stamp; then
if test -f "$WORKSPACE/jenkins/failure-stamp"; then
echo "Something went wrong:"
cat $WORKSPACE/jenkins/pr-comments.md
cat "$WORKSPACE/jenkins/pr-comments.md"
exit 1
fi