diff --git a/docs-preview-annotate b/bin/docs-preview-annotate similarity index 100% rename from docs-preview-annotate rename to bin/docs-preview-annotate diff --git a/pipeline-annotate b/bin/pipeline-annotate similarity index 100% rename from pipeline-annotate rename to bin/pipeline-annotate diff --git a/pipeline-generate b/bin/pipeline-generate similarity index 100% rename from pipeline-generate rename to bin/pipeline-generate diff --git a/bin/trigger-pipeline b/bin/trigger-pipeline new file mode 100755 index 00000000..a63ffe35 --- /dev/null +++ b/bin/trigger-pipeline @@ -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) diff --git a/bin/update-initial-pipelines b/bin/update-initial-pipelines new file mode 100755 index 00000000..24f1ba77 --- /dev/null +++ b/bin/update-initial-pipelines @@ -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") diff --git a/lib/buildkite/config/diff.rb b/lib/buildkite/config/diff.rb index 66c7994f..d7a08df4 100644 --- a/lib/buildkite/config/diff.rb +++ b/lib/buildkite/config/diff.rb @@ -13,12 +13,17 @@ def self.compare def self.generated_pipeline(repo) File.symlink(repo, "tmp/rails/.buildkite") - command = ["ruby", ".buildkite/pipeline-generate"] + Dir.chdir("tmp/rails") do + bin = if File.exist?(".buildkite/bin/pipeline-generate") + ".buildkite/bin/pipeline-generate" + else + ".buildkite/pipeline-generate" + end + command = ["ruby", bin] - pipeline = "rails-ci" - command.push(pipeline) + pipeline = "rails-ci" + command.push(pipeline) - Dir.chdir("tmp/rails") do io = IO.popen(command) output = io.read io.close diff --git a/lib/buildkite/config/docker_build.rb b/lib/buildkite/config/docker_build.rb index 3e899940..60607bf2 100644 --- a/lib/buildkite/config/docker_build.rb +++ b/lib/buildkite/config/docker_build.rb @@ -14,7 +14,18 @@ def builder(ruby:, &block) label ":docker: #{build_context.ruby.prefix}#{build_context.ruby.version}" key "docker-image-#{build_context.ruby.image_key}" plugin :artifacts, { - download: %w[.dockerignore .buildkite/* .buildkite/**/*] + download: ".dockerignore" + } + plugin :artifacts, { + download: %w[ + .buildkite/.empty + .buildkite/docker-compose.yml + .buildkite/Dockerfile + .buildkite/Dockerfile.beanstalkd + .buildkite/mysql-initdb.d + .buildkite/runner + ], + compressed: ".buildkite.tgz" } plugin :docker_compose, { diff --git a/lib/buildkite/config/rake_command.rb b/lib/buildkite/config/rake_command.rb index cd61e4c2..6820ee7d 100644 --- a/lib/buildkite/config/rake_command.rb +++ b/lib/buildkite/config/rake_command.rb @@ -53,7 +53,18 @@ def rake(dir = "", task = "test", service: "default", pre_steps: [], &block) command "rake #{task}" plugin :artifacts, { - download: %w[.buildkite/* .buildkite/**/*] + download: ".dockerignore" + } + plugin :artifacts, { + download: %w[ + .buildkite/.empty + .buildkite/docker-compose.yml + .buildkite/Dockerfile + .buildkite/Dockerfile.beanstalkd + .buildkite/mysql-initdb.d + .buildkite/runner + ], + compressed: ".buildkite.tgz" } plugin :docker_compose, { diff --git a/buildkite-config-initial-pipeline.yml b/pipelines/buildkite-config/initial.yml similarity index 90% rename from buildkite-config-initial-pipeline.yml rename to pipelines/buildkite-config/initial.yml index 79c3c790..1e2bb2ae 100644 --- a/buildkite-config-initial-pipeline.yml +++ b/pipelines/buildkite-config/initial.yml @@ -58,7 +58,7 @@ steps: -v "$$PWD/tmp":/app/tmp:rw -e BUNDLE_FROZEN ruby:latest - ./pipeline-annotate + ./bin/pipeline-annotate - command: | mkdir -p tmp sh -c "$$ANNOTATE_COMMAND" > tmp/annotate-nightly.diff @@ -81,7 +81,7 @@ steps: -e RAILS_CI_NIGHTLY -e BUNDLE_FROZEN ruby:latest - ./pipeline-annotate + ./bin/pipeline-annotate - group: label: ":rails: Rails CI" @@ -102,7 +102,6 @@ steps: env: CONFIG_REPO: "${BUILDKITE_PULL_REQUEST_REPO}" CONFIG_BRANCH: "${BUILDKITE_BRANCH}" - BUILDKITE_CONFIG_TRIGGER: true # This variable can be used downstream to avoid things like "if branch==main do Y" - block: "Rails CI stable" key: block-rails-ci-stable prompt: | @@ -118,7 +117,6 @@ steps: env: CONFIG_REPO: "${BUILDKITE_PULL_REQUEST_REPO}" CONFIG_BRANCH: "${BUILDKITE_BRANCH}" - BUILDKITE_CONFIG_TRIGGER: true # This variable can be used downstream to avoid things like "if branch==main do Y" - block: "Rails CI nightly" key: block-rails-ci-nightly-main prompt: | @@ -134,7 +132,6 @@ steps: env: CONFIG_REPO: "${BUILDKITE_PULL_REQUEST_REPO}" CONFIG_BRANCH: "${BUILDKITE_BRANCH}" - BUILDKITE_CONFIG_TRIGGER: true # This variable can be used downstream to avoid things like "if branch==main do Y" - block: "Rails CI nightly stable" key: block-rails-ci-nightly-stable prompt: | @@ -150,4 +147,3 @@ steps: env: CONFIG_REPO: "${BUILDKITE_PULL_REQUEST_REPO}" CONFIG_BRANCH: "${BUILDKITE_BRANCH}" - BUILDKITE_CONFIG_TRIGGER: true # This variable can be used downstream to avoid things like "if branch==main do Y" diff --git a/docs-preview-initial-pipeline.yml b/pipelines/docs-preview/initial.yml similarity index 63% rename from docs-preview-initial-pipeline.yml rename to pipelines/docs-preview/initial.yml index 5a4e33da..3e47eb1c 100644 --- a/docs-preview-initial-pipeline.yml +++ b/pipelines/docs-preview/initial.yml @@ -9,19 +9,13 @@ steps: command: | PATH=/bin:/usr/bin set -e - echo "+++ No .buildkite/; using fallback repository" - rm -rf .buildkite - - if [ -n "$$CONFIG_REPO" ]; then - GIT_REPO="$$CONFIG_REPO" - elif [ -n "$$CONFIG_FORK" ]; then - GIT_REPO="https://github.com/$$CONFIG_FORK/buildkite-config" + if [ -d ".buildkite" ]; then + echo "+++ :bk-status-failed: .buildkite/ already exists; please remove it and try again" + exit 1 else - GIT_REPO="https://github.com/rails/buildkite-config" - fi - GIT_BRANCH="$${CONFIG_BRANCH-main}" - GIT_BRANCH="$${GIT_BRANCH#*:}" + GIT_REPO="https://github.com/rails/buildkite-config" + GIT_BRANCH="main" echo "Cloning buildkite-config:" echo "git clone -b \"$$GIT_BRANCH\" \"$$GIT_REPO\" .buildkite" @@ -29,10 +23,20 @@ steps: rm -rf .buildkite/.git sh -c "$$PIPELINE_COMMAND" + ([ -f .buildkite/.dockerignore ] && cp .buildkite/.dockerignore .dockerignore) || true plugins: - - artifacts#v1.2.0: - upload: [".buildkite/**/*", ".dockerignore"] + - 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: PIPELINE_COMMAND: >- docker run --rm @@ -50,5 +54,5 @@ steps: -e RUN_QUEUE -e QUEUE ruby:latest - .buildkite/pipeline-generate docs-preview | + .buildkite/bin/pipeline-generate docs-preview | buildkite-agent pipeline upload diff --git a/pipelines/docs-preview/pipeline.rb b/pipelines/docs-preview/pipeline.rb index 60d42f64..f559656a 100644 --- a/pipelines/docs-preview/pipeline.rb +++ b/pipelines/docs-preview/pipeline.rb @@ -2,8 +2,7 @@ Buildkite::Builder.pipeline do plugin :docker, "docker#v5.10.0" - plugin :artifacts, "artifacts#v1.2.0" - # plugin :artifacts, "artifacts#v1.9.2" + plugin :artifacts, "artifacts#v1.9.3" command do label "build", emoji: :rails @@ -23,7 +22,9 @@ "BUNDLE_WITHOUT=db:job:cable:storage:ujs", ], } - artifact_paths "preview.tar.gz" + plugin :artifacts, { + upload: "preview.tar.gz" + } end command do @@ -41,7 +42,9 @@ ], image: "node:latest" } - plugin :artifacts, { download: "preview.tar.gz" } + plugin :artifacts, { + download: "preview.tar.gz" + } command "tar -xzf preview.tar.gz" command "npm install wrangler" command "npx wrangler pages publish preview --project-name=$CLOUDFLARE_PAGES_PROJECT --branch=\"$BUILDKITE_BRANCH\"" diff --git a/pipelines/rails-ci-nightly/initial.yml b/pipelines/rails-ci-nightly/initial.yml new file mode 100644 index 00000000..4e585930 --- /dev/null +++ b/pipelines/rails-ci-nightly/initial.yml @@ -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}" diff --git a/pipelines/rails-ci/initial.yml b/pipelines/rails-ci/initial.yml new file mode 100644 index 00000000..f884f442 --- /dev/null +++ b/pipelines/rails-ci/initial.yml @@ -0,0 +1,68 @@ +# This file is never read -- it's just a copy of the pipeline's +# configuration in the Buildkite UI. + +steps: + - name: ":pipeline: rails-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: + BUNDLE_FROZEN: true + PIPELINE_COMMAND: >- + docker run --rm + -v "$$PWD":/app:ro -w /app + -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}" diff --git a/rails-initial-pipeline.yml b/rails-initial-pipeline.yml deleted file mode 100644 index 2ff6d143..00000000 --- a/rails-initial-pipeline.yml +++ /dev/null @@ -1,86 +0,0 @@ -# This file is never read -- it's just a copy of the pipeline's -# configuration in the Buildkite UI. - -steps: - - name: ":pipeline: rails-initial-pipeline" - command: | - PATH=/bin:/usr/bin - set -e - treesha="$$(git ls-tree -d HEAD .buildkite | awk '{print $$3}')" - if [ -z "$${treesha}" ]; then - echo "+++ No .buildkite/; using fallback repository" - rm -rf .buildkite - - if [ -n "$$CONFIG_REPO" ]; then - GIT_REPO="$$CONFIG_REPO" - elif [ -n "$$CONFIG_FORK" ]; then - GIT_REPO="https://github.com/$$CONFIG_FORK/buildkite-config" - 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" - elif [ "$${#treesha}" -lt 40 ]; then - echo "Short SHA for .buildkite/" - exit 1 - elif curl -s -S "https://gist.githubusercontent.com/matthewd/3f98bcc9957c8ddf2204a390bf3a6cdd/raw/list" | grep -a -F -x "$${treesha}"; then - echo "+++ Known tree; generating pipeline" - echo ".buildkite/ tree is $${treesha}" - sh -c "$$PIPELINE_COMMAND" - else - echo "+++ Unknown tree; requesting approval" - echo ".buildkite/ tree is $${treesha}" - buildkite-agent pipeline upload <<'NESTED' - steps: - - block: "Review Build Script" - prompt: | - This commit uses new build configuration. Please review the changes in .buildkite/ carefully before unblocking. - - name: ":pipeline:" - command: >- - $$PIPELINE_COMMAND - plugins: - - artifacts#v1.2.0: - download: - - ".buildkite/*" - - ".buildkite/**/*" - timeout_in_minutes: 5 - agents: - queue: "$$BUILDKITE_AGENT_META_DATA_QUEUE" - NESTED - fi - ([ -f .buildkite/.dockerignore ] && cp .buildkite/.dockerignore .dockerignore) || true - plugins: - - artifacts#v1.2.0: - upload: [".buildkite/**/*", ".dockerignore"] - env: - BUNDLE_FROZEN: true - PIPELINE_COMMAND: >- - docker run --rm - -v "$$PWD":/app:ro -w /app - -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/pipeline-generate rails-ci | - buildkite-agent pipeline upload - timeout_in_minutes: 5 - agents: - queue: "${QUEUE-builder}" diff --git a/rails-nightly-initial-pipeline.yml b/rails-nightly-initial-pipeline.yml deleted file mode 100644 index 8b493547..00000000 --- a/rails-nightly-initial-pipeline.yml +++ /dev/null @@ -1,88 +0,0 @@ -# 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 - treesha="$$(git ls-tree -d HEAD .buildkite | awk '{print $$3}')" - if [ -z "$${treesha}" ]; then - echo "+++ No .buildkite/; using fallback repository" - rm -rf .buildkite - - if [ -n "$$CONFIG_REPO" ]; then - GIT_REPO="$$CONFIG_REPO" - elif [ -n "$$CONFIG_FORK" ]; then - GIT_REPO="https://github.com/$$CONFIG_FORK/buildkite-config" - 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" - elif [ "$${#treesha}" -lt 40 ]; then - echo "Short SHA for .buildkite/" - exit 1 - elif curl -s -S "https://gist.githubusercontent.com/matthewd/3f98bcc9957c8ddf2204a390bf3a6cdd/raw/list" | grep -a -F -x "$${treesha}"; then - echo "+++ Known tree; generating pipeline" - echo ".buildkite/ tree is $${treesha}" - sh -c "$$PIPELINE_COMMAND" - else - echo "+++ Unknown tree; requesting approval" - echo ".buildkite/ tree is $${treesha}" - buildkite-agent pipeline upload <<'NESTED' - steps: - - block: "Review Build Script" - prompt: | - This commit uses new build configuration. Please review the changes in .buildkite/ carefully before unblocking. - - name: ":pipeline:" - command: >- - $$PIPELINE_COMMAND - plugins: - - artifacts#v1.2.0: - download: - - ".buildkite/*" - - ".buildkite/**/*" - timeout_in_minutes: 5 - agents: - queue: "$$BUILDKITE_AGENT_META_DATA_QUEUE" - NESTED - fi - ([ -f .buildkite/.dockerignore ] && cp .buildkite/.dockerignore .dockerignore) || true - plugins: - - artifacts#v1.2.0: - upload: [".buildkite/**/*", ".dockerignore"] - 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/pipeline-generate rails-ci | - buildkite-agent pipeline upload - timeout_in_minutes: 5 - agents: - queue: "${QUEUE-builder}" diff --git a/test/buildkite_config/test_docker_build.rb b/test/buildkite_config/test_docker_build.rb index 6ad880d7..61941693 100644 --- a/test/buildkite_config/test_docker_build.rb +++ b/test/buildkite_config/test_docker_build.rb @@ -25,8 +25,16 @@ def test_builder "encrypted_0fb9444d0374_iv" => nil }, "timeout_in_minutes" => 15, "plugins" => - [{ "artifacts#v1.0" => - { "download" => [".dockerignore", ".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "build" => "base", "config" => ".buildkite/docker-compose.yml", @@ -72,8 +80,16 @@ def test_builder_gem_version "encrypted_0fb9444d0374_iv" => nil }, "timeout_in_minutes" => 15, "plugins" => - [{ "artifacts#v1.0" => - { "download" => [".dockerignore", ".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "build" => "base", "config" => ".buildkite/docker-compose.yml", diff --git a/test/buildkite_config/test_rake_command.rb b/test/buildkite_config/test_rake_command.rb index 29233ee4..13db787a 100644 --- a/test/buildkite_config/test_rake_command.rb +++ b/test/buildkite_config/test_rake_command.rb @@ -66,7 +66,16 @@ def test_command "env" => { "IMAGE_NAME" => "buildkite-config-base:ruby-3-2-local" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -96,7 +105,16 @@ def test_default_task "env" => { "IMAGE_NAME" => "buildkite-config-base:ruby-3-2-local" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -127,7 +145,16 @@ def test_multiple "env" => { "IMAGE_NAME" => "buildkite-config-base:3-2-local" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -143,7 +170,16 @@ def test_multiple "env" => { "IMAGE_NAME" => "buildkite-config-base:3-2-local" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -173,7 +209,16 @@ def test_docker_compose_plugin "env" => { "IMAGE_NAME" => "buildkite-config-base:3-2-local" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "myservice", @@ -204,7 +249,16 @@ def test_env_yjit "soft_fail" => true, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -236,7 +290,16 @@ def test_env_pre_steps "env" => { "IMAGE_NAME" => "buildkite-config-base:3-2-local", "PRE_STEPS" => "rm Gemfile.lock && bundle install" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -269,7 +332,16 @@ def test_agents "env" => { "IMAGE_NAME" => "buildkite-config-base:3-2-local" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -302,7 +374,16 @@ def test_artifact_paths "env" => { "IMAGE_NAME" => "buildkite-config-base:3-2-local" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -338,7 +419,16 @@ def test_automatic_retry_on "env" => { "IMAGE_NAME" => "buildkite-config-base:3-2-local" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -371,7 +461,16 @@ def test_timeout_in_minutes "env" => { "IMAGE_NAME" => "buildkite-config-base:3-2-local" }, "timeout_in_minutes" => 10, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -405,7 +504,16 @@ def test_soft_fail "timeout_in_minutes" => 30, "soft_fail" => true, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -438,7 +546,16 @@ def test_soft_fail_ruby "timeout_in_minutes" => 30, "soft_fail" => true, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -471,7 +588,16 @@ def test_rake_with_block "env" => { "IMAGE_NAME" => "buildkite-config-base:3-2-local", "MYSQL_IMAGE" => "mariadb:latest" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -501,7 +627,16 @@ def test_rake_mysql_image_and_task_rails "env" => { "IMAGE_NAME" => "buildkite-config-base:3-2-local" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "default", @@ -533,7 +668,16 @@ def test_rake_mysql_image_and_task_rails_5_x "POSTGRES_IMAGE" => "postgres:9.6-alpine" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "mysqldb", @@ -565,7 +709,16 @@ def test_rake_mysql_image_and_task_rails_4_x "POSTGRES_IMAGE" => "postgres:9.6-alpine" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "mysqldb", @@ -597,7 +750,16 @@ def test_rake_postgres_image_and_task_rails_5_1 "POSTGRES_IMAGE" => "postgres:9.6-alpine" }, "timeout_in_minutes" => 30, "plugins" => - [{ "artifacts#v1.0" => { "download" => [".buildkite/*", ".buildkite/**/*"] } }, + [{ "artifacts#v1.0" => { "download" => ".dockerignore" } }, + { "artifacts#v1.0" => + { "download" => + [".buildkite/.empty", + ".buildkite/docker-compose.yml", + ".buildkite/Dockerfile", + ".buildkite/Dockerfile.beanstalkd", + ".buildkite/mysql-initdb.d", + ".buildkite/runner"], + "compressed" => ".buildkite.tgz" } }, { "docker-compose#v1.0" => { "env" => ["PRE_STEPS", "RACK"], "run" => "postgresdb", diff --git a/update-initial-pipelines b/update-initial-pipelines deleted file mode 100755 index 812b4242..00000000 --- a/update-initial-pipelines +++ /dev/null @@ -1,56 +0,0 @@ -#!/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, configuration) - client = Buildkit.new(token: buildkite_token) - resp = client.update_pipeline("rails", pipeline, { - configuration: configuration - }) - puts resp.steps -end - -# Update rails/rails -puts "Updating rails/rails..." -rails_init = File.read("rails-initial-pipeline.yml") -update_pipeline("rails", rails_init) - -puts "\n" * 2; puts "#####"; puts "\n" * 2 - -# Update rails/rails-nightly -puts "Updating rails/rails-nightly..." -rails_nightly_init = File.read("rails-nightly-initial-pipeline.yml") -update_pipeline("rails-nightly", rails_nightly_init) - -puts "\n" * 2; puts "#####"; puts "\n" * 2 - -# Update rails/rails-ci -puts "Updating rails/rails-ci..." -update_pipeline("rails-ci", rails_init) - -puts "\n" * 2; puts "#####"; puts "\n" * 2 - -# Update rails/rails-ci-nightly -puts "Updating rails/rails-ci-nightly..." -rails_nightly_init = File.read("rails-nightly-initial-pipeline.yml") -update_pipeline("rails-ci-nightly", rails_nightly_init) - -puts "\n" * 2; puts "#####"; puts "\n" * 2 - -# Update rails/buildkite-config -puts "Updating rails/buildkite-config..." -buildkite_config_init = File.read("buildkite-config-initial-pipeline.yml") -update_pipeline("buildkite-config", buildkite_config_init) - -# Update rails/docs-preview -puts "Updating rails/docs-preview..." -docs_preview_config_init = File.read("docs-preview-initial-pipeline.yml") -update_pipeline("docs-preview", docs_preview_config_init)