-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from rails/rm-refactor-bin
Organize bin and initial pipeline files into sub-folders
- Loading branch information
Showing
18 changed files
with
467 additions
and
282 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
# Example usage: | ||
# bin/trigger-pipeline [options] org pipeline [slug] | ||
|
||
require "buildkit" | ||
require "optparse" | ||
|
||
def buildkite_token | ||
ENV.fetch("BUILDKITE_TOKEN") { | ||
raise "BUILDKITE_TOKEN undefined!\nMake sure your BUILDKITE_TOKEN has `write_builds` scope too!" | ||
} | ||
end | ||
|
||
# Make sure your BUILDKITE_TOKEN has `write_builds` scope | ||
def trigger_pipeline(org, pipeline, slug, branch: "main", commit: "HEAD") | ||
slug ||= pipeline | ||
puts "Trigger build for #{pipeline}..." | ||
configuration = File.read("pipelines/#{slug}/initial.yml") | ||
client = Buildkit.new(token: buildkite_token) | ||
resp = client.create_build(org, pipeline, { | ||
branch: branch, | ||
commit: commit, | ||
override_steps_configuration: configuration | ||
}) | ||
puts resp.web_url | ||
end | ||
|
||
options = {} | ||
OptionParser.new do |opts| | ||
opts.on("--branch=BRANCH") | ||
opts.on("--commit=COMMIT") | ||
end.parse!(into: options) | ||
|
||
org = ARGV.shift | ||
pipeline = ARGV.shift | ||
slug = ARGV.shift | ||
|
||
trigger_pipeline(org, pipeline, slug, **options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require "buildkit" | ||
|
||
def buildkite_token | ||
ENV.fetch("BUILDKITE_TOKEN") { | ||
raise "BUILDKITE_TOKEN undefined!\nMake sure your BUILDKITE_TOKEN has `write_pipelines` scope too!" | ||
} | ||
end | ||
|
||
# Make sure your BUILDKITE_TOKEN has `write_pipelines` scope | ||
def update_pipeline(pipeline, slug = nil) | ||
slug ||= pipeline | ||
puts "Updating #{pipeline}..." | ||
configuration = File.read("pipelines/#{slug}/initial.yml") | ||
client = Buildkit.new(token: buildkite_token) | ||
resp = client.update_pipeline("rails", pipeline, { | ||
configuration: configuration | ||
}) | ||
puts resp.steps | ||
end | ||
|
||
update_pipeline("rails", "rails-ci") | ||
update_pipeline("rails-ci", "rails-ci") | ||
update_pipeline("rails-nightly", "rails-ci-nightly") | ||
update_pipeline("rails-ci-nightly", "rails-ci-nightly") | ||
update_pipeline("buildkite-config", "buildkite-config") | ||
update_pipeline("docs-preview", "docs-preview") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# This file is never read -- it's just a copy of the pipeline's | ||
# configuration in the Buildkite UI. | ||
|
||
steps: | ||
- name: ":pipeline: rails-nightly-initial-pipeline" | ||
command: | | ||
PATH=/bin:/usr/bin | ||
set -e | ||
if [ -d ".buildkite" ]; then | ||
echo "+++ :bk-status-failed: .buildkite/ already exists; please remove it and try again" | ||
exit 1 | ||
fi | ||
if [ -n "$$CONFIG_REPO" ]; then | ||
GIT_REPO="$$CONFIG_REPO" | ||
else | ||
GIT_REPO="https://github.com/rails/buildkite-config" | ||
fi | ||
GIT_BRANCH="$${CONFIG_BRANCH-main}" | ||
GIT_BRANCH="$${GIT_BRANCH#*:}" | ||
echo "Cloning buildkite-config:" | ||
echo "git clone -b \"$$GIT_BRANCH\" \"$$GIT_REPO\" .buildkite" | ||
git clone -b "$$GIT_BRANCH" "$$GIT_REPO" .buildkite | ||
rm -rf .buildkite/.git | ||
sh -c "$$PIPELINE_COMMAND" | ||
([ -f .buildkite/.dockerignore ] && cp .buildkite/.dockerignore .dockerignore) || true | ||
plugins: | ||
- artifacts#v1.9.3: | ||
upload: ".dockerignore" | ||
- artifacts#v1.9.3: | ||
upload: | ||
- .buildkite/.empty | ||
- .buildkite/docker-compose.yml | ||
- .buildkite/Dockerfile | ||
- .buildkite/Dockerfile.beanstalkd | ||
- .buildkite/mysql-initdb.d | ||
- .buildkite/runner | ||
compressed: ".buildkite.tgz" | ||
env: | ||
RAILS_CI_NIGHTLY: true | ||
BUNDLE_FROZEN: true | ||
PIPELINE_COMMAND: >- | ||
docker run --rm | ||
-v "$$PWD":/app:ro -w /app | ||
-e RAILS_CI_NIGHTLY | ||
-e CI | ||
-e BUILDKITE | ||
-e BUILDKITE_AGENT_META_DATA_QUEUE | ||
-e BUILDKITE_BRANCH | ||
-e BUILDKITE_BUILD_ID | ||
-e BUILDKITE_PULL_REQUEST | ||
-e BUILDKITE_PULL_REQUEST_BASE_BRANCH | ||
-e BUILDKITE_REBUILT_FROM_BUILD_ID | ||
-e BUILD_QUEUE | ||
-e BUNDLE_FROZEN | ||
-e DOCKER_IMAGE | ||
-e RUN_QUEUE | ||
-e QUEUE | ||
ruby:latest | ||
.buildkite/bin/pipeline-generate rails-ci | | ||
buildkite-agent pipeline upload | ||
timeout_in_minutes: 5 | ||
agents: | ||
queue: "${QUEUE-builder}" |
Oops, something went wrong.