Skip to content

Commit

Permalink
Rework buildkite pipeline construction to be more composable
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Jun 11, 2020
1 parent 8b3dc2d commit e2d4637
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 103 deletions.
23 changes: 5 additions & 18 deletions .buildkite/pipeline-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,10 @@

set -e
cd "$(dirname "$0")"/..
source ci/_

if [[ -n $BUILDKITE_TAG ]]; then
buildkite-agent annotate --style info --context release-tag \
"https://github.com/solana-labs/solana/releases/$BUILDKITE_TAG"
buildkite-agent pipeline upload ci/buildkite-release.yml
else
if [[ $BUILDKITE_BRANCH =~ ^pull ]]; then
# Add helpful link back to the corresponding Github Pull Request
buildkite-agent annotate --style info --context pr-backlink \
"Github Pull Request: https://github.com/solana-labs/solana/$BUILDKITE_BRANCH"
fi
_ ci/buildkite/pipeline.sh pipeline.yml
echo +++ pipeline
cat pipeline.yml

if [[ $BUILDKITE_MESSAGE =~ GitBook: ]]; then
buildkite-agent annotate --style info --context gitbook-ci-skip \
"GitBook commit detected, CI skipped"
exit
fi

buildkite-agent pipeline upload ci/buildkite.yml
fi
_ buildkite-agent pipeline upload pipeline.yml
15 changes: 0 additions & 15 deletions ci/buildkite-release.yml

This file was deleted.

38 changes: 0 additions & 38 deletions ci/buildkite.yml

This file was deleted.

8 changes: 4 additions & 4 deletions ci/buildkite-tests.yml → ci/buildkite/all-tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# These steps are conditionally triggered by ci/buildkite.yml when files
# other than those in docs/ are modified

steps:
- command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_nightly_docker_image ci/test-checks.sh"
name: "checks"
timeout_in_minutes: 20
- wait
- command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_nightly_docker_image ci/test-coverage.sh"
name: "coverage"
timeout_in_minutes: 30
Expand Down
6 changes: 6 additions & 0 deletions ci/buildkite/dependabot-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- command: "ci/dependabot-pr.sh"
name: "dependabot"
timeout_in_minutes: 5
if: build.env("GITHUB_USER") == "dependabot-preview[bot]"

- wait
2 changes: 2 additions & 0 deletions ci/buildkite/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- command: "docs/build.sh"
timeout_in_minutes: 5
82 changes: 82 additions & 0 deletions ci/buildkite/pipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env bash
#
# Builds a buildkite pipeline based on the environment variables
#

set -e
cd "$(dirname "$0")"/../..

output_file=${1:-/dev/stderr}

start_pipeline() {
echo "# $*" > "$output_file"
echo "steps:" >> "$output_file"
}

wait_step() {
echo " - wait" >> "$output_file"
}

cat_steps() {
cat "$@" >> "$output_file"
}

pull_or_push_steps() {
cat_steps ci/buildkite/sanity.yml
wait_step

if ci/affects-files.sh .sh$; then
cat_steps ci/buildkite/shellcheck.yml
fi
wait_step

docs=false
all_tests=false

if ci/affects-files.sh ^docs/; then
docs=true
fi

if ci/affects-files.sh !^docs/ !.md$ !^.buildkite/; then
all_tests=true
fi

if $docs; then
cat_steps ci/buildkite/docs.yml
fi

if $all_tests; then
cat_steps ci/buildkite/all-tests.yml
fi
}


if [[ -n $BUILDKITE_TAG ]]; then
start_pipeline "Tag pipeline for $BUILDKITE_TAG"

buildkite-agent annotate --style info --context release-tag \
"https://github.com/solana-labs/solana/releases/$BUILDKITE_TAG"

# Jump directly to the secondary build to publish release artifacts quickly
cat_steps ci/buildkite/trigger-secondary.yml
exit 0
fi


if [[ $BUILDKITE_BRANCH =~ ^pull ]]; then
start_pipeline "Pull request pipeline for $BUILDKITE_BRANCH"

# Add helpful link back to the corresponding Github Pull Request
buildkite-agent annotate --style info --context pr-backlink \
"Github Pull Request: https://github.com/solana-labs/solana/$BUILDKITE_BRANCH"

cat_steps ci/buildkite/dependabot-pr.yml
pull_or_push_steps
exit 0
fi

start_pipeline "Push pipeline for $BUILDKITE_BRANCH"
pull_or_push_steps
wait_step
cat_steps ci/buildkite/trigger-secondary.yml
exit 0
3 changes: 3 additions & 0 deletions ci/buildkite/sanity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- command: "ci/test-sanity.sh"
name: "sanity"
timeout_in_minutes: 5
3 changes: 3 additions & 0 deletions ci/buildkite/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- command: "ci/shellcheck.sh"
name: "shellcheck"
timeout_in_minutes: 5
9 changes: 9 additions & 0 deletions ci/buildkite/trigger-secondary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- trigger: "solana-secondary"
branches: "!pull/*"
async: true
build:
message: "${BUILDKITE_MESSAGE}"
commit: "${BUILDKITE_COMMIT}"
branch: "${BUILDKITE_BRANCH}"
env:
TRIGGERED_BUILDKITE_TAG: "${BUILDKITE_TAG}"
21 changes: 0 additions & 21 deletions ci/maybe-trigger-tests.sh

This file was deleted.

11 changes: 4 additions & 7 deletions ci/test-checks.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
#
# cargo fmt, cargo clippy
#
set -e

cd "$(dirname "$0")/.."
Expand All @@ -10,9 +13,6 @@ source ci/rust-version.sh nightly
export RUST_BACKTRACE=1
export RUSTFLAGS="-D warnings"

# Look for failed mergify.io backports
_ git show HEAD --check --oneline

if _ scripts/cargo-for-all-lock-files.sh +"$rust_nightly" check --locked --all-targets; then
true
else
Expand All @@ -22,6 +22,7 @@ else
exit "$check_status"
fi

_ ci/order-crates-for-publishing.py
_ cargo +"$rust_stable" fmt --all -- --check

# -Z... is needed because of clippy bug: https://github.com/rust-lang/rust-clippy/issues/4612
Expand All @@ -30,10 +31,6 @@ _ cargo +"$rust_nightly" clippy -Zunstable-options --workspace --all-targets --

_ cargo +"$rust_stable" audit --version
_ scripts/cargo-for-all-lock-files.sh +"$rust_stable" audit --ignore RUSTSEC-2020-0002 --ignore RUSTSEC-2020-0008
_ ci/nits.sh
_ ci/order-crates-for-publishing.py
_ docs/build.sh
_ ci/check-ssh-keys.sh

{
cd programs/bpf
Expand Down
14 changes: 14 additions & 0 deletions ci/test-sanity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e

cd "$(dirname "$0")/.."

source ci/_

# Look for failed mergify.io backports
_ git show HEAD --check --oneline

_ ci/nits.sh
_ ci/check-ssh-keys.sh

echo --- ok

0 comments on commit e2d4637

Please sign in to comment.