diff --git a/.gitmodules b/.gitmodules index 514f175ea5..65d9ff3257 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "prisma-query"] path = server/prisma-rs/libs/prisma-query url = https://github.com/prisma/prisma-query.git +[submodule "server/.buildkite/build-cli"] + path = server/.buildkite/build-cli + url = https://github.com/prisma/build-cli.git diff --git a/server/.buildkite/build-cli b/server/.buildkite/build-cli new file mode 160000 index 0000000000..d8d720d0f3 --- /dev/null +++ b/server/.buildkite/build-cli @@ -0,0 +1 @@ +Subproject commit d8d720d0f3e301ce30531259787c544cec8b02a0 diff --git a/server/.buildkite/build-cli/cli.rb b/server/.buildkite/build-cli/cli.rb deleted file mode 100755 index 25f5d7694e..0000000000 --- a/server/.buildkite/build-cli/cli.rb +++ /dev/null @@ -1,98 +0,0 @@ -require_relative './src/build_context' -require_relative './src/command' -require_relative './src/commands' - -Dir.chdir(__dir__) - -git_fetch -context = BuildContext.new - -unless context.should_build? - puts "Nothing to do" - exit 0 -end - -def print_usage - puts """Prisma Build Tool -Usage: cli - -Subcommands: -\tpipeline -\t\tRenders the pipeline based on the current build context and uploads it to buildkite. - -\ttest -\t\tTests given sbt project against the given connector. - -\tbuild -\t\tBuilds and tags the docker image(s) on the current branch with the given tag. Additional tags to process are inferred from the given tag. - -\tnative-image -\t\tBuilds the native image on the current branch. Artifacts are always published to S3. is the version string to be baked into the binary. -\t\t: Denotes the platform, e.g. `debian`, `lambda`. - -\trust-binary -\t\tCompiles the Prisma Rust binary on the current platform on the current CI branch. Artifacts are always published to S3. -\t\t: native (bare on the machine without docker), debian, alpine - -\ttest-rust -\t\truns the tests for prisma-rs -""" -end - -if ARGV.length <= 0 - print_usage - exit 1 -end - -command = ARGV[0] - -case command -when "pipeline" - upload_pipeline(context) - -when "test" - if ARGV.length <= 1 - print_usage - exit 1 - end - - project = ARGV[1] - if ARGV[2].nil? - connector = :none - else - connector = ARGV[2].to_sym - end - - test_project(context, project, connector) - -when "build" - if ARGV.length < 1 - print_usage - exit 1 - end - - build_images(context, Tag.new(ARGV[1])) - -when "native-image" - if ARGV.length < 2 - print_usage - exit 1 - end - - native_image(context, ARGV[1], ARGV[2]) - -when "rust-binary" - if ARGV.length < 2 - print_usage - exit 1 - end - - rust_binary(context, ARGV[1]) - -when "test-rust" - test_rust(context) - -else - puts "Invalid command: #{command}" - exit 1 -end \ No newline at end of file diff --git a/server/.buildkite/build-cli/src/build_context.rb b/server/.buildkite/build-cli/src/build_context.rb deleted file mode 100644 index 1d48bc2a5f..0000000000 --- a/server/.buildkite/build-cli/src/build_context.rb +++ /dev/null @@ -1,177 +0,0 @@ -require 'rbconfig' -require 'pathname' -require 'uri' -require 'net/http' -require 'json' -require_relative './command' - -class BuildContext - attr_accessor :branch, :tag, :commit, :last_git_tag, :server_root_path - - def initialize - @branch = ENV["BUILDKITE_BRANCH"] || nil - @tag = (ENV["BUILDKITE_TAG"].nil? || ENV["BUILDKITE_TAG"].empty?) ? nil : Tag.new(ENV["BUILDKITE_TAG"]) - @commit = ENV["BUILDKITE_COMMIT"] || nil - @last_git_tag = get_last_git_tag - @server_root_path = find_server_root - end - - def get_last_git_tag - last_tags = Command.new("git", "tag", "--sort=-version:refname").run!.raise! - filtered = last_tags.get_stdout.lines.map(&:chomp).select { |tag| !tag.empty? && !tag.include?("beta") && !tag.start_with?("v") } - Tag.new(filtered.first) - end - - def get_last_docker_tag_for(tag_prefix) - uri = URI.parse("https://registry.hub.docker.com/v2/repositories/prismagraphql/prisma/tags/") - tags = [] - depth = 3 # Pagination depth max to retrieve tags - - loop do - response = Net::HTTP.get_response(uri) - code = response.code.to_i - - if code >= 200 && code < 300 - tags_json = JSON.parse(response.body) - - if tags_json['next'] != nil && depth > 0 - depth -= 1 - uri = URI.parse(tags_json['next']) - tags_json['results'].each do |tag| - tags.push tag['name'] - end - else - break - end - - elsif code == 301 - uri = URI.parse(response.header['location']) - - else - response.each_header do |key, value| - p "#{key} => #{value}" - end - raise "Failed to fetch docker tags for Prisma: #{response.code} #{response.body}" - end - end - - tag = tags.find do |tag| - tag != "latest" && !tag.include?("heroku") && tag.include?(tag_prefix) - end - - if tag != nil - Tag.new(tag) - else - nil - end - end - - def cli_invocation_path - "#{server_root_path}/.buildkite/pipeline.sh" - end - - def is_windows? - os == :windows - end - - def is_nix? - os == :macosx || os == :unix || os == :linux - end - - def should_build? - (server_changed? || tag != nil) && buildkite_build? - end - - def server_changed? - if commit.nil? - false - else - res = Command.new("git", "diff", "--exit-code", "--name-only", "#{commit}", "#{commit}~1", "--", "../../").puts!.run! - !res.success? - end - end - - def buildkite_build? - @branch != "local" - end - - def connectors - [:mongo, :postgres, :mysql, :sqlite, :"sqlite-native"] # :"native-integration-tests" - end - - def native_image_targets - [:debian, :lambda] - end - - def os - @os ||= ( - host_os = RbConfig::CONFIG['host_os'] - case host_os - when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ - :windows - when /darwin|mac os/ - :macosx - when /linux/ - :linux - when /solaris|bsd/ - :unix - else - raise "Unknown host system: #{host_os.inspect}" - end - ) - end - - def find_server_root - Pathname.new(Dir.pwd).parent.dirname - end -end - -class Tag - attr_accessor :major, :minor, :patch, :channel, :revision - - def initialize(tag) - unless tag.nil? || !tag.include?(".") - chunked = tag.split("-") - raw_version = chunked[0] - - if chunked.length >= 2 - @channel = chunked[1] - end - - if chunked.length == 3 - @revision = chunked[2].to_i - end - - @major, @minor, @patch = raw_version.split(".").map { |x| x.to_i } - end - end - - def nil? - @major.nil? || @minor.nil? - end - - def beta? - !nil? && @channel == "beta" - end - - def stable? - !nil? && @channel.nil? - end - - def stringify - if nil? - "" - else - stringified = "#{@major}.#{@minor}#{@patch.nil? ? "" : ".#{@patch}"}" - unless @channel.nil? - stringified += "-#{@channel}" - end - - unless @revision.nil? - stringified += "-#{@revision}" - end - - stringified - end - end -end \ No newline at end of file diff --git a/server/.buildkite/build-cli/src/command.rb b/server/.buildkite/build-cli/src/command.rb deleted file mode 100644 index fa7fd703ea..0000000000 --- a/server/.buildkite/build-cli/src/command.rb +++ /dev/null @@ -1,114 +0,0 @@ -require 'open3' - -class Command - attr_accessor :stdin, :cmd, :args, :stream_output, :pipe_to, :env - - def initialize(command, *arguments) - @cmd = command - @args = arguments - @stream_output = false - @env = {} - end - - def with_env(env) - @env = env - self - end - - ## input: array of strings - def with_stdin(input) - self.stdin = input - self - end - - def puts! - @stream_output = true - self - end - - def pipe_stdout_to(other_command) - self.pipe_to = other_command - self - end - - def stringify - "#{cmd} #{args.join(" ")}" - end - - def run! - outputs = { :stdout => [], :stderr => [] } - - begin - Open3.popen3(@env.merge(ENV.to_h), cmd, *args, unsetenv_others: true) do |s_in, stdout, stderr, thread| - unless stdin.nil? - stdin.each { |line| s_in.puts line } - s_in.close - end - - { :stdout => stdout, :stderr => stderr }.each do |stream_key, stream| - Thread.new do - while line = stream.gets do - outputs[stream_key].push line - puts "[#{stream_key}]: #{line}" if stream_output - end - end - end - - thread.join - exit_status = thread.value - result = ExecResult.new(self, exit_status, outputs[:stdout], outputs[:stderr]) - - if pipe_to != nil && result.success? - pipe_to.with_stdin(result.stdout).run! - else - ExecResult.new(self, exit_status, outputs[:stdout], outputs[:stderr]) - end - end - rescue => e - ExecResult.new(self, -1, [], ["Exception: #{e}", "No such command, file, or directory: #{cmd}"]) - end - end -end - -class ExecResult - attr_accessor :status, :stdout, :stderr, :command - - def initialize(origin, status, stdout, stderr) - @command = origin - @status = status - @stdout = stdout - @stderr = stderr - end - - def get_stdout - stdout.join("") - end - - def get_stderr - stderr.join("") - end - - def print_stdout - puts get_stdout - end - - def print_stderr - puts get_stderr - end - - def success? - status == 0 - end - - def raise! - unless success? - raise <<~EOS - Command '#{@command.stringify}' exited with #{status} - #{stdout.empty? ? "" : "\nStdout: --------\n#{get_stdout}"} - #{stderr.empty? ? "" : "\nStderr: --------\n#{get_stderr}"} - EOS - end - - self - end -end \ No newline at end of file diff --git a/server/.buildkite/build-cli/src/commands.rb b/server/.buildkite/build-cli/src/commands.rb deleted file mode 100644 index 2a6a1785f1..0000000000 --- a/server/.buildkite/build-cli/src/commands.rb +++ /dev/null @@ -1,163 +0,0 @@ -require_relative './pipeline_renderer' -require_relative './command' -require_relative './docker' - -def upload_pipeline(context) - yml = PipelineRenderer.new(context).render! - res = Command.new("buildkite-agent", "pipeline", "upload").with_stdin([yml]).run!.raise! - - if res.success? - puts "Successfully uploaded pipeline" - end -end - -def test_project(context, project, connector) - DockerCommands.kill_all - DockerCommands.run_tests_for(context, project, connector) -end - -def test_rust(context) - DockerCommands.run_rust_tests(context) -end - -def build_images(context, tag) - DockerCommands.kill_all - raise "Invalid version to build images from." if tag.nil? - - tags_to_build = [tag.stringify] - tags_to_build.push(infer_additional_tags(context, tag)) - - DockerCommands.build(context, tag) - DockerCommands.tag_and_push(context, tags_to_build.flatten.compact) - - # Because buildkite doesn't give us the underlying branch on a tagged build, we need to infer it. - if context.tag.nil? || !context.tag.stable? - trigger_dependent_pipeline(context.branch, tags_to_build) - elsif context.tag.stable? - trigger_dependent_pipeline("master", tags_to_build) - end -end - -def native_image(context, target, version_str) - parsed_version = Tag.new(version_str) - artifact_s3_paths = ["s3://#{ENV["GRAAL_ARTIFACT_BUCKET"]}/#{context.branch}/#{target}/#{context.commit}"] - - if parsed_version.stable? - version_to_build = [version_str, infer_additional_tags(context, parsed_version)].flatten.compact.find do |version| - # Always use the long version (x.y.z) - /\d*(\.\d*){2}/.match(version) - end - - # Also store as latest - artifact_s3_paths.push "s3://#{ENV["GRAAL_ARTIFACT_BUCKET"]}/#{context.branch}/#{target}/latest" - elsif context.branch == "alpha" || context.branch == "beta" - version_to_build = version_str - artifact_s3_paths.push "s3://#{ENV["GRAAL_ARTIFACT_BUCKET"]}/#{context.branch}/#{target}/latest" - else - version_to_build = version_str - end - - # Produces a binary in the target folder - DockerCommands.native_image(context, version_to_build, "build-image:#{target}") - Dir.chdir("#{context.server_root_path}/images/prisma-native/target/prisma-native-image") # Necessary to keep the buildkite agent from prefixing the binary when uploading - - artifact_s3_paths.each do |path| - Command.new("buildkite-agent", "artifact", "upload", "prisma-native").with_env({ - "BUILDKITE_ARTIFACT_UPLOAD_DESTINATION" => path - }).puts!.run!.raise! - end -end - -def artifact_paths_for(context, target_name) - artifact_s3_paths = ["s3://#{ENV["RUST_ARTIFACT_BUCKET"]}/#{context.branch}/#{context.commit}/#{target_name}"] - - if context.branch == "alpha" || context.branch == "beta" - artifact_s3_paths.push "s3://#{ENV["RUST_ARTIFACT_BUCKET"]}/#{context.branch}/latest/#{target_name}" - end - - artifact_s3_paths -end - -def rust_binary(context, platform) - artifact_paths = [] - if platform == "alpine" - artifact_paths.push(artifact_paths_for(context, "linux-musl")) - DockerCommands.rust_binary_musl(context) - Dir.chdir("#{context.server_root_path}/prisma-rs/target/x86_64-unknown-linux-musl/release") # Necessary to keep the buildkite agent from prefixing the binary when uploading - - elsif platform == "debian" - artifact_paths.push(artifact_paths_for(context, "linux-glibc")) - DockerCommands.rust_binary(context) - Dir.chdir("#{context.server_root_path}/prisma-rs/target/release") # Necessary to keep the buildkite agent from prefixing the binary when uploading - - elsif platform == "native" - artifact_paths.push(artifact_paths_for(context, "darwin")) - Command.new('cargo', 'build', "--manifest-path=#{context.server_root_path}/prisma-rs/Cargo.toml", "--release").with_env({ - "RUSTC_WRAPPER" => "sccache" - }).puts!.run!.raise! - Dir.chdir("#{context.server_root_path}/prisma-rs/target/release") # Necessary to keep the buildkite agent from prefixing the binary when uploading - - else - raise "Unsupported platform #{platform}" - end - - artifact_paths.flatten.each do |path| - Command.new("buildkite-agent", "artifact", "upload", "prisma").with_env({ - "BUILDKITE_S3_DEFAULT_REGION" => "eu-west-1", - "BUILDKITE_ARTIFACT_UPLOAD_DESTINATION" => path - }).puts!.run!.raise! - end -end - -def trigger_dependent_pipeline(channel, tags) - pipeline_input = <<~EOS - - trigger: \"prisma-cloud\" - label: \":cloud: Trigger Prisma Cloud Tasks #{tags.join(", ")} :cloud:\" - async: true - build: - env: - BUILD_TAGS: \"#{tags.join(',')}\" - CHANNEL: \"#{channel}\" - EOS - - res = Command.new("buildkite-agent", "pipeline", "upload").with_stdin([pipeline_input]).run!.raise! -end - -def infer_additional_tags(context, tag) - additional_tags = [] - - unless tag.nil? - if tag.stable? || tag.beta? - if tag.patch.nil? - # E.g. not only tag 1.30(-beta), but also 1.30.0(-beta) - additional_tag = tag.dup - additional_tag.patch = 0 - additional_tags.push additional_tag.stringify - else - # E.g. not only tag 1.30.0(-beta), but also 1.30(-beta) - additional_tag = tag.dup - additional_tag.patch = nil - additional_tags.push additional_tag.stringify - end - else - if tag.revision.nil? - # E.g. not only tag 1.30-beta, but also 1.30-beta-1 - additional_tag = tag.dup - additional_tag.revision = 1 - additional_tags.push additional_tag.stringify - else - # E.g. not only tag 1.30-beta-1, but also 1.30-beta - additional_tag = tag.dup - additional_tag.revision = nil - additional_tags.push additional_tag.stringify - end - end - end - - additional_tags -end - -# Eliminates consistency issues on buildkite -def git_fetch - Command.new("git", "fetch", "--tags").run!.raise! -end \ No newline at end of file diff --git a/server/.buildkite/build-cli/src/docker.rb b/server/.buildkite/build-cli/src/docker.rb deleted file mode 100644 index 3ab43b5e48..0000000000 --- a/server/.buildkite/build-cli/src/docker.rb +++ /dev/null @@ -1,105 +0,0 @@ -require_relative './command' - -class DockerCommands - @images = ["prisma", "prisma-prod"] - - def self.kill_all - puts "Stopping all docker containers..." - containers = Command.new("docker", "ps", "-q").run!.raise! - containers.stdout.each do |container| - puts "\tStopping #{container.chomp}..." - Command.new("docker", "kill", container.chomp).run!.raise! - end - end - - def self.run_tests_for(context, project, connector) - compose_flags = ["--project-name", "#{project}", "--file", "#{context.server_root_path}/.buildkite/docker-test-setups/docker-compose.test.#{connector}.yml"] - - # Start rabbit and db, wait a bit for init - puts "Starting dependency services..." - deps = Command.new("docker-compose", *compose_flags, "up", "-d", "test-db", "rabbit").puts!.run!.raise! - - sleep(15) - - puts "Starting tests for #{project}..." - test_run = Command.new("docker-compose", *compose_flags, "run", "app", "sbt", "-mem", "3072", "#{project}/test").puts!.run!.raise! - - puts "Stopping dependency services..." - cleanup = Command.new("docker-compose", *compose_flags, "kill").puts!.run!.raise! - - # Only the test run result is important - test_run - end - - def self.run_rust_tests(context) - Command.new("docker", "run", - "-e", "SERVER_ROOT=/root/build", - "-e", "RUST_BACKTRACE=1", - '-w', '/root/build/prisma-rs', - '-v', "#{context.server_root_path}:/root/build", - 'prismagraphql/build-image:debian', - './test.sh').puts!.run!.raise! - end - - def self.build(context, prisma_version) - Command.new("docker", "run", - "-e", "SERVER_ROOT=/root/build", - "-e", "BRANCH=#{context.branch}", - "-e", "COMMIT_SHA=#{context.commit}", - "-e", "CLUSTER_VERSION=#{prisma_version.stringify}", - '-w', '/root/build', - '-v', "#{context.server_root_path}:/root/build", - '-v', "#{File.expand_path('~')}/.ivy2:/root/.ivy2", - '-v', "#{File.expand_path('~')}/.coursier:/root/.coursier", - '-v', '/var/run/docker.sock:/var/run/docker.sock', - 'prismagraphql/build-image:debian', - 'sbt', 'docker').puts!.run!.raise! - end - - def self.tag_and_push(context, tags) - # On the stable channel we additionally release -graalvm versions, running on graalvm. - from_tags = context.branch == 'master' ? ['latest', 'graalvm'] : ['latest'] - - @images.product(from_tags, tags).each do |image, from_tag, to_tag| - suffix = from_tag == 'graalvm' ? '-graalvm' : '' - - puts "Tagging and pushing prismagraphql/#{image}:#{from_tag} image with #{to_tag}#{suffix}..." - Command.new("docker", "tag", "prismagraphql/#{image}:#{from_tag}", "prismagraphql/#{image}:#{to_tag}#{suffix}").puts!.run!.raise! - Command.new("docker", "push", "prismagraphql/#{image}:#{to_tag}#{suffix}").puts!.run!.raise! - end - end - - def self.native_image(context, prisma_version, build_image) - Command.new("docker", "run", - "-e", "SERVER_ROOT=/root/build", - "-e", "BRANCH=#{context.branch}", - "-e", "COMMIT_SHA=#{context.commit}", - "-e", "CLUSTER_VERSION=#{prisma_version}", - '-w', '/root/build', - '-v', "#{context.server_root_path}:/root/build", - '-v', "#{File.expand_path('~')}/.ivy2:/root/.ivy2", - '-v', "#{File.expand_path('~')}/.coursier:/root/.coursier", - '-v', '/var/run/docker.sock:/var/run/docker.sock', - "prismagraphql/#{build_image}", - 'sbt', 'project prisma-native', "prisma-native-image:packageBin").puts!.run!.raise! - end - - def self.rust_binary_musl(context) - Command.new("docker", "run", - '-w', '/root/build', - '-e', 'CC=gcc', - '-v', "#{context.server_root_path}:/root/build", - 'prismagraphql/build-image:alpine', - 'cargo', 'build', "--target=x86_64-unknown-linux-musl", "--manifest-path=prisma-rs/query-engine/prisma/Cargo.toml", "--release").puts!.run!.raise! - end - - def self.rust_binary(context) - Command.new("docker", "run", - '-w', '/root/build', - '-v', "#{context.server_root_path}:/root/build", - '-v', '/var/run/docker.sock:/var/run/docker.sock', - '-v', "#{File.expand_path('~')}/cargo_cache:/root/cargo_cache", - "prismagraphql/build-image:debian", - 'cargo', 'build', "--manifest-path=prisma-rs/Cargo.toml", "--release").puts!.run!.raise! - end -end \ No newline at end of file diff --git a/server/.buildkite/build-cli/src/pipeline_renderer.rb b/server/.buildkite/build-cli/src/pipeline_renderer.rb deleted file mode 100644 index 33a09e6942..0000000000 --- a/server/.buildkite/build-cli/src/pipeline_renderer.rb +++ /dev/null @@ -1,207 +0,0 @@ -require_relative './pipeline_step' - -class PipelineRenderer - # Rules to generate the test excution - # Valid connectors: :all, :none, :mongo, :mysql, :postgres - # https://github.com/buildkite/emojis - @@test_rules = { - :'api-connector-mysql' => { - :label => ":mysql: MySql API connector", - :connectors => [:mysql] - }, - :'deploy-connector-mysql' => { - :label => ":mysql: MySql deploy connector", - :connectors => [:mysql] - }, - :'integration-tests-mysql' => { - :label => ":slot_machine: Integration tests", - :connectors => [:mysql, :postgres] - }, - :'api-connector-postgres' => { - :label => ":postgres: Postgres API connector", - :connectors => [:postgres] - }, - :'deploy-connector-postgres' => { - :label => ":postgres: Postgres deploy connector", - :connectors => [:postgres] - }, - :'api-connector-mongo' => { - :label => ":piedpiper: MongoDB API connector", - :connectors => [:mongo] - }, - :'deploy-connector-mongo' => { - :label => ":piedpiper: MongoDB deploy connector", - :connectors => [:mongo] - }, - :'libs' => { - :label => ":scala: Libraries", - :connectors => [:none] - }, - :'subscriptions' => { - :label => ":scala: Subscriptions", - :connectors => [:postgres] - }, - :'shared-models' => { - :label => ":scala: Subscriptions", - :connectors => [:none] - }, - :'images' => { - :label => ":scala: Images", - :connectors => [:all] - }, - :'deploy' => { - :label => ":scala: Deploy", - :connectors => [:all] - }, - :'api' => { - :label => ":scala: API", - :connectors => [:all] - }, - :'workers' => { - :label => ":scala: Workers", - :connectors => [:all] - } - } - - @@wait_step = PipelineStep.new.wait! - - def initialize(context) - @context = context - end - - def render! - steps = collect_steps - rendered = <<~EOS - steps: - #{steps.compact.map { |step| step.render!(2) }.join "\n\n"} - EOS - - puts rendered - rendered - end - - def collect_steps - release_steps = release_artifacts_steps - [ test_steps, - rust_tests, - release_steps[:before_wait], - @@wait_step, - release_rust_artifacts, - release_steps[:after_wait]].flatten - end - - def test_steps - @@test_rules.map do |service, rule| - rule[:connectors].map do |connector| - case connector - when :all - @context.connectors.map do |registered_connector| - PipelineStep.new - .label("#{rule[:label]} [#{registered_connector}]") - .command("./server/.buildkite/pipeline.sh test #{service} #{registered_connector}") - end - - when :none - PipelineStep.new - .label(rule[:label]) - .command("./server/.buildkite/pipeline.sh test #{service}") - - else - PipelineStep.new - .label(rule[:connectors].length > 1 ? "#{rule[:label]} [#{connector}]" : rule[:label]) - .command("./server/.buildkite/pipeline.sh test #{service} #{connector == :none ? "" : connector}") - end - end - end.flatten - end - - def rust_tests - PipelineStep.new - .label(":rust: Cargo test prisma-rs") - .command("./server/.buildkite/pipeline.sh test-rust") - end - - def release_rust_artifacts - [ - PipelineStep.new - .label(":rust: Build & Publish :linux: glibc") - .command("./server/.buildkite/pipeline.sh rust-binary debian"), - PipelineStep.new - .label(":rust: Build & Publish :linux: musl") - .command("./server/.buildkite/pipeline.sh rust-binary alpine"), - PipelineStep.new - .label(":rust: Build & Publish :darwin:") - .command("./server/.buildkite/pipeline.sh rust-binary native") - .queue("macos") - ] - end - - def release_artifacts_steps - # Option 1: It's a tag on master -> check branches match and build stable images for next tag. - # Option 2: It's a tag on beta -> check branches match and build beta image. - # Option 3: It's a tag, but on beta -> check branches match and add step to build beta image. todo: Useful? - # Option 4: It's a normal build on either alpha or beta. Release images with incremented revision of the last tag on the channel. - # Everything else doesn't trigger image builds, only build native images for compile-checks - - steps = { - :before_wait => [], - :after_wait => [] - } - - if @context.tag != nil && @context.tag.stable? && @context.branch == @context.tag.stringify - # steps[:before_wait] = build_steps_for(@context.tag.stringify) - steps[:after_wait].push PipelineStep.new - .label(":docker: Release stable #{@context.tag.stringify}") - .command("./server/.buildkite/pipeline.sh build #{@context.tag.stringify}") - - elsif @context.tag != nil && @context.tag.beta? && @context.branch == @context.tag.stringify - next_tag = @context.branch - # steps[:before_wait] = build_steps_for(next_tag) - steps[:after_wait].push PipelineStep.new - .label(":docker: Release #{@context.branch} #{next_tag}") - .command("./server/.buildkite/pipeline.sh build #{next_tag}") - - elsif @context.branch == "alpha" || @context.branch == "beta" - next_tag = calculate_next_unstable_docker_tag() - # steps[:before_wait] = build_steps_for(next_tag.stringify) - steps[:after_wait].push PipelineStep.new - .label(":docker: Release #{@context.branch} #{next_tag.stringify}") - .command("./server/.buildkite/pipeline.sh build #{next_tag.stringify}") - - else - # steps[:before_wait] = build_steps_for(@context.branch) - end - - steps - end - - def build_steps_for(version) - # ['debian', 'lambda'].map do |target| - # PipelineStep.new - # .label(":rust: Native image [#{target}] [#{version}]") - # .command("./server/.buildkite/pipeline.sh native-image #{target} #{version}") - # .queue("native-linux") - # end - [] - end - - def calculate_next_unstable_docker_tag() - @next_docker_tag ||= lambda do - new_tag = @context.last_git_tag.dup - new_tag.channel = @context.branch - new_tag.patch = nil # Ignore patches for unstable releases - new_tag.minor += (@context.branch == "alpha") ? 2 : 1 - last_docker_tag = @context.get_last_docker_tag_for("#{new_tag.stringify}-") # Check for previous revision of the unstable version - - if last_docker_tag.nil? - new_tag.revision = 1 - else - new_tag.revision = last_docker_tag.revision + 1 - end - - new_tag - end.call - - @next_docker_tag - end -end diff --git a/server/.buildkite/build-cli/src/pipeline_step.rb b/server/.buildkite/build-cli/src/pipeline_step.rb deleted file mode 100644 index 542f027952..0000000000 --- a/server/.buildkite/build-cli/src/pipeline_step.rb +++ /dev/null @@ -1,58 +0,0 @@ -class PipelineStep - def initialize - @label = "" - @command = "" - @queue = nil - @branches = [] - @wait = false - end - - def wait! - @wait = true - self - end - - def label(l) - @label = l - self - end - - def command(c) - @command = c - self - end - - def queue(q) - @queue = q - self - end - - def branches(b) - @branches = b - self - end - - def render!(indent = 2) - if @wait - return " " * indent + "- wait" - end - - rendered = [ - "- label: \"#{@label}\"", - " command: #{@command}" - ] - - unless @branches.empty? - rendered.push " branches: #{@branches.join(' ')}" - end - - unless @queue.nil? - rendered += [ - " agents:", - " queue: #{@queue}" - ] - end - - rendered.map { |render| " " * indent + render }.join("\n") - end -end \ No newline at end of file diff --git a/server/.buildkite/docker-test-setups/docker-compose.test.mongo.yml b/server/.buildkite/docker-test-setups/docker-compose.test.mongo.yml deleted file mode 100644 index 1d674fcd3a..0000000000 --- a/server/.buildkite/docker-test-setups/docker-compose.test.mongo.yml +++ /dev/null @@ -1,48 +0,0 @@ -version: "3" -services: - app: - image: prismagraphql/build-image:debian - environment: - SERVER_ROOT: /root/build - CLUSTER_VERSION: "latest" - COMMIT_SHA: "123abcd" - PACKAGECLOUD_PW: "${PACKAGECLOUD_PW}" - RABBITMQ_URI: amqp://rabbit - RUST_BACKTRACE: "1" - PRISMA_CONFIG: | - port: 4466 - rabbitUri: amqp://rabbit - databases: - default: - connector: mongo - uri: mongodb://prisma:prisma@test-db:27017/?authSource=admin&ssl=false - volumes: - - ../..:/root/build - - ~/.ivy2:/root/.ivy2 - - ~/.coursier:/root/.coursier - working_dir: /root/build - networks: - - tests - - test-db: - image: mongo:3.6 - restart: always - environment: - MONGO_INITDB_ROOT_USERNAME: prisma - MONGO_INITDB_ROOT_PASSWORD: prisma - ports: - - "27017" - networks: - - tests - - rabbit: - image: rabbitmq:3.7.2-management - restart: always - ports: - - "5672:5672" - - "15672:15672" - networks: - - tests - -networks: - tests: diff --git a/server/.buildkite/docker-test-setups/docker-compose.test.mysql.yml b/server/.buildkite/docker-test-setups/docker-compose.test.mysql.yml deleted file mode 100644 index cd0966fe8e..0000000000 --- a/server/.buildkite/docker-test-setups/docker-compose.test.mysql.yml +++ /dev/null @@ -1,56 +0,0 @@ -version: "3" -services: - app: - image: prismagraphql/build-image:debian - environment: - SERVER_ROOT: /root/build - CLUSTER_VERSION: "latest" - COMMIT_SHA: "123abcd" - PACKAGECLOUD_PW: "${PACKAGECLOUD_PW}" - RABBITMQ_URI: amqp://rabbit - RUST_BACKTRACE: "1" - PRISMA_CONFIG: | - port: 4466 - rabbitUri: amqp://rabbit - databases: - default: - connector: mysql - migrations: true - host: test-db - port: 3306 - user: root - password: prisma - rawAccess: true - volumes: - - ../..:/root/build - - ~/.ivy2:/root/.ivy2 - - ~/.coursier:/root/.coursier - working_dir: /root/build - networks: - - tests - - test-db: - image: mysql:5.7 - command: mysqld - restart: always - environment: - MYSQL_USER: root - MYSQL_ROOT_PASSWORD: prisma - MYSQL_DATABASE: prisma - ports: - - "3306" - networks: - - tests - tmpfs: /var/lib/mysql - - rabbit: - image: rabbitmq:3.7.2-management - restart: always - ports: - - "5672:5672" - - "15672:15672" - networks: - - tests - -networks: - tests: diff --git a/server/.buildkite/docker-test-setups/docker-compose.test.native-integration-tests.yml b/server/.buildkite/docker-test-setups/docker-compose.test.native-integration-tests.yml deleted file mode 100644 index 0796a1220f..0000000000 --- a/server/.buildkite/docker-test-setups/docker-compose.test.native-integration-tests.yml +++ /dev/null @@ -1,58 +0,0 @@ -version: "3" -services: - app: - image: prismagraphql/build-image:debian - environment: - SERVER_ROOT: /root/build - CLUSTER_VERSION: "latest" - COMMIT_SHA: "123abcd" - PACKAGECLOUD_PW: "${PACKAGECLOUD_PW}" - RABBITMQ_URI: amqp://rabbit - RUST_BACKTRACE: "1" - PRISMA_CONFIG: | - port: 4466 - rabbitUri: amqp://rabbit - prototype: true - databases: - default: - connector: native-integration-tests - migrations: true - active: true - host: test-db - port: 3306 - user: root - password: prisma - rawAccess: true - volumes: - - ../..:/root/build - - ~/.ivy2:/root/.ivy2 - - ~/.coursier:/root/.coursier - working_dir: /root/build - networks: - - tests - - test-db: - image: mysql:5.7 - command: mysqld - restart: always - environment: - MYSQL_USER: root - MYSQL_ROOT_PASSWORD: prisma - MYSQL_DATABASE: prisma - ports: - - "3306" - networks: - - tests - tmpfs: /var/lib/mysql - - rabbit: - image: rabbitmq:3.7.2-management - restart: always - ports: - - "5672:5672" - - "15672:15672" - networks: - - tests - -networks: - tests: diff --git a/server/.buildkite/docker-test-setups/docker-compose.test.none.yml b/server/.buildkite/docker-test-setups/docker-compose.test.none.yml deleted file mode 100644 index 40508cc54c..0000000000 --- a/server/.buildkite/docker-test-setups/docker-compose.test.none.yml +++ /dev/null @@ -1,58 +0,0 @@ -# Prisma tests still require a db to be present for initialization, so just boot a mysql -# As soon as we fixed the test setup, we can omit the dummy db here. -version: "3" -services: - app: - image: prismagraphql/build-image:debian - environment: - SERVER_ROOT: /root/build - CLUSTER_VERSION: "latest" - COMMIT_SHA: "123abcd" - PACKAGECLOUD_PW: "${PACKAGECLOUD_PW}" - RABBITMQ_URI: amqp://rabbit - RUST_BACKTRACE: "1" - PRISMA_CONFIG: | - port: 4466 - rabbitUri: amqp://rabbit - databases: - default: - connector: mysql - migrations: true - host: test-db - port: 3306 - user: root - password: prisma - rawAccess: true - volumes: - - ../..:/root/build - - ~/.ivy2:/root/.ivy2 - - ~/.coursier:/root/.coursier - working_dir: /root/build - networks: - - tests - - test-db: - image: mysql:5.7 - command: mysqld - restart: always - environment: - MYSQL_USER: root - MYSQL_ROOT_PASSWORD: prisma - MYSQL_DATABASE: prisma - ports: - - "3306" - networks: - - tests - tmpfs: /var/lib/mysql - - rabbit: - image: rabbitmq:3.7.2-management - restart: always - ports: - - "5672:5672" - - "15672:15672" - networks: - - tests - -networks: - tests: diff --git a/server/.buildkite/docker-test-setups/docker-compose.test.postgres-passive.yml b/server/.buildkite/docker-test-setups/docker-compose.test.postgres-passive.yml deleted file mode 100644 index 8550db0074..0000000000 --- a/server/.buildkite/docker-test-setups/docker-compose.test.postgres-passive.yml +++ /dev/null @@ -1,56 +0,0 @@ -version: "3" -services: - app: - image: prismagraphql/build-image:debian - environment: - SERVER_ROOT: /root/build - CLUSTER_VERSION: "latest" - COMMIT_SHA: "123abcd" - PACKAGECLOUD_PW: "${PACKAGECLOUD_PW}" - RABBITMQ_URI: amqp://rabbit - RUST_BACKTRACE: "1" - PRISMA_CONFIG: | - port: 4466 - rabbitUri: amqp://rabbit - databases: - default: - connector: postgres - migrations: false - host: test-db - port: 5432 - user: postgres - password: prisma - rawAccess: true - volumes: - - ../..:/root/build - - ~/.ivy2:/root/.ivy2 - - ~/.coursier:/root/.coursier - working_dir: /root/build - networks: - - tests - - test-db: - image: postgres:10.3 - restart: always - command: postgres -c 'max_connections=1000' - environment: - POSTGRES_PASSWORD: "prisma" - PGDATA: "/pgtmpfs" - ports: - - "5432" - networks: - - tests - tmpfs: /pgtmpfs - - rabbit: - image: rabbitmq:3.7.2-management - restart: always - hostname: rabbit-host - ports: - - "5672:5672" - - "15672:15672" - networks: - - tests - -networks: - tests: diff --git a/server/.buildkite/docker-test-setups/docker-compose.test.postgres.yml b/server/.buildkite/docker-test-setups/docker-compose.test.postgres.yml deleted file mode 100644 index 9237afa5c2..0000000000 --- a/server/.buildkite/docker-test-setups/docker-compose.test.postgres.yml +++ /dev/null @@ -1,56 +0,0 @@ -version: "3" -services: - app: - image: prismagraphql/build-image:debian - environment: - SERVER_ROOT: /root/build - CLUSTER_VERSION: "latest" - COMMIT_SHA: "123abcd" - PACKAGECLOUD_PW: "${PACKAGECLOUD_PW}" - RABBITMQ_URI: amqp://rabbit - RUST_BACKTRACE: "1" - PRISMA_CONFIG: | - port: 4466 - rabbitUri: amqp://rabbit - databases: - default: - connector: postgres - migrations: true - host: test-db - port: 5432 - user: postgres - password: prisma - rawAccess: true - volumes: - - ../..:/root/build - - ~/.ivy2:/root/.ivy2 - - ~/.coursier:/root/.coursier - working_dir: /root/build - networks: - - tests - - test-db: - image: postgres:10.3 - restart: always - command: postgres -c 'max_connections=1000' - environment: - POSTGRES_PASSWORD: "prisma" - PGDATA: "/pgtmpfs" - ports: - - "5432" - networks: - - tests - tmpfs: /pgtmpfs - - rabbit: - image: rabbitmq:3.7.2-management - restart: always - hostname: rabbit-host - ports: - - "5672:5672" - - "15672:15672" - networks: - - tests - -networks: - tests: diff --git a/server/.buildkite/docker-test-setups/docker-compose.test.sqlite-native.yml b/server/.buildkite/docker-test-setups/docker-compose.test.sqlite-native.yml deleted file mode 100644 index 83cd4ca80b..0000000000 --- a/server/.buildkite/docker-test-setups/docker-compose.test.sqlite-native.yml +++ /dev/null @@ -1,58 +0,0 @@ -version: "3" -services: - app: - image: prismagraphql/build-image:debian - environment: - SERVER_ROOT: /root/build - CLUSTER_VERSION: "latest" - COMMIT_SHA: "123abcd" - PACKAGECLOUD_PW: "${PACKAGECLOUD_PW}" - RABBITMQ_URI: amqp://rabbit - RUST_BACKTRACE: "1" - PRISMA_CONFIG: | - port: 4466 - rabbitUri: amqp://rabbit - prototype: true - databases: - default: - connector: sqlite-native - migrations: true - active: true - host: test-db - port: 3306 - user: root - password: prisma - rawAccess: true - volumes: - - ../..:/root/build - - ~/.ivy2:/root/.ivy2 - - ~/.coursier:/root/.coursier - working_dir: /root/build - networks: - - tests - - test-db: - image: mysql:5.7 - command: mysqld - restart: always - environment: - MYSQL_USER: root - MYSQL_ROOT_PASSWORD: prisma - MYSQL_DATABASE: prisma - ports: - - "3306" - networks: - - tests - tmpfs: /var/lib/mysql - - rabbit: - image: rabbitmq:3.7.2-management - restart: always - ports: - - "5672:5672" - - "15672:15672" - networks: - - tests - -networks: - tests: diff --git a/server/.buildkite/docker-test-setups/docker-compose.test.sqlite.yml b/server/.buildkite/docker-test-setups/docker-compose.test.sqlite.yml deleted file mode 100644 index fe1a1696ce..0000000000 --- a/server/.buildkite/docker-test-setups/docker-compose.test.sqlite.yml +++ /dev/null @@ -1,57 +0,0 @@ -version: "3" -services: - app: - image: prismagraphql/build-image:debian - environment: - SERVER_ROOT: /root/build - CLUSTER_VERSION: "latest" - COMMIT_SHA: "123abcd" - PACKAGECLOUD_PW: "${PACKAGECLOUD_PW}" - RABBITMQ_URI: amqp://rabbit - RUST_BACKTRACE: "1" - PRISMA_CONFIG: | - port: 4466 - rabbitUri: amqp://rabbit - prototype: true - databases: - default: - connector: sqlite - migrations: true - host: test-db - port: 3306 - user: root - password: prisma - rawAccess: true - volumes: - - ../..:/root/build - - ~/.ivy2:/root/.ivy2 - - ~/.coursier:/root/.coursier - working_dir: /root/build - networks: - - tests - - test-db: - image: mysql:5.7 - command: mysqld - restart: always - environment: - MYSQL_USER: root - MYSQL_ROOT_PASSWORD: prisma - MYSQL_DATABASE: prisma - ports: - - "3306" - networks: - - tests - tmpfs: /var/lib/mysql - - rabbit: - image: rabbitmq:3.7.2-management - restart: always - ports: - - "5672:5672" - - "15672:15672" - networks: - - tests - -networks: - tests: diff --git a/server/.buildkite/hooks/pre-command b/server/.buildkite/hooks/pre-command deleted file mode 100755 index 1459a61deb..0000000000 --- a/server/.buildkite/hooks/pre-command +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -docker kill $(docker ps -q) &> /dev/null -echo "Stopped all old docker containers..." - -echo $(pwd) \ No newline at end of file diff --git a/server/.buildkite/scripts/docker-native/Dockerfile b/server/.buildkite/scripts/docker-native/Dockerfile deleted file mode 100644 index 62d04e5509..0000000000 --- a/server/.buildkite/scripts/docker-native/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -# Dockerfile for native image -FROM debian:stretch -COPY prisma-native /app/prisma-native -RUN chmod +x /app/prisma-native -ENTRYPOINT /app/prisma-native \ No newline at end of file diff --git a/server/.buildkite/scripts/docker-native/build.sh b/server/.buildkite/scripts/docker-native/build.sh deleted file mode 100755 index e9552e6f58..0000000000 --- a/server/.buildkite/scripts/docker-native/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -set -e -TAG="${1:?Provide the tag this script is building}" - -cd "$(dirname "$0")" - -SCRIPT_ROOT=$(dirname "$(pwd)") -BK_ROOT=$(dirname "$SCRIPT_ROOT") -SERVER_ROOT=$(dirname "$BK_ROOT") - -cp ${SERVER_ROOT}/images/prisma-native/target/prisma-native-image/prisma-native . - -docker build -t prismagraphql/prisma-native:${TAG} . -docker push prismagraphql/prisma-native:${TAG} - -rm prisma-native