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
require 'uri' | |
require 'net/http' | |
require 'net/https' | |
require 'json' | |
GRAPHQL_API_KEY = ENV.fetch("GRAPHQL_API_KEY") | |
def perform_graphql_query(query, variables) | |
# This is our Buildkite GraphQL Endpoint. | |
uri = URI.parse("https://graphql.buildkite.com/v1") |
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
# Add to `spec/support/database_state_loader.rb` | |
class DatabaseStateLoader | |
class EnvironmentError < RuntimeError; end | |
def self.load(path) | |
new(path).load | |
end | |
def initialize(path) |
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
# Add this file to `spec/support/rails_log_splitter.rb` | |
require "stringio" | |
require "logger" | |
require "fileutils" | |
class RailsLogSplitter | |
def initialize(all: false) | |
@io = StringIO.new | |
@logger = Logger.new(@io) |
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
class IDSequenceResetter | |
def reset(connection) | |
@cached_sql ||= {} | |
sql = @cached_sql[connection] ||= | |
begin | |
sequences = connection.execute(%{SELECT c.relname FROM pg_class c WHERE c.relkind = 'S'}).values.flatten | |
"".tap do |sql| | |
sequences.each do |name| | |
next if not name.ends_with?("id_seq") |
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
# Add this file to `spec/support/timecop.rb` | |
# | |
# Usage: | |
# | |
# it "should touch the `updated_at` attribute", :timecop do | |
# ... | |
# end | |
require 'timecop' |
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
# Add this file to `spec/support/active_record_id_tracer.rb` | |
module ActiveRecordIDTracer | |
def insert(*args) | |
super(*args).tap do |returned_id| | |
Rails.logger.debug("\033[1m\033[33mActiveRecordIDTracer\033[0m #{klass.name} insert returned ID #{returned_id}") | |
end | |
end | |
end |
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
# Add this file to `spec/support/simple_database_cleaner.rb` | |
class SimpleDatabaseCleaner | |
def clean(connection) | |
@cached_sql ||= {} | |
sql = @cached_sql[connection] ||= | |
begin | |
"".tap do |sql| | |
connection.tables.each do |table_name| | |
next if table_name == "schema_migrations".freeze |
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
#!/usr/bin/env ruby | |
# | |
# Usage: | |
# ./flood --pipeline "my-org/bash-dumper" --api-key ... -n 20 | |
require 'net/http' | |
require 'optparse' | |
require 'json' | |
options = { pipeline: "", api_key: "", endpoint: "https://api.buildkite.com", commit: "HEAD", branch: "master", number: 5 } |
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
execve("./pty-test", ["./pty-test"], [/* 21 vars */]) = 0 | |
arch_prctl(ARCH_SET_FS, 0x5fb988) = 0 | |
sched_getaffinity(0, 8192, {1, 0, 0, 0}) = 32 | |
mmap(0xc000000000, 65536, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc000000000 | |
munmap(0xc000000000, 65536) = 0 | |
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7f8851a000 | |
mmap(0xc820000000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc820000000 | |
mmap(0xc81fff8000, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc81fff8000 | |
mmap(0xc000000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc000000000 | |
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7f8850a000 |
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
execve("./pty-test", ["./pty-test"], [/* 20 vars */]) = 0 | |
arch_prctl(ARCH_SET_FS, 0x5fb988) = 0 | |
sched_getaffinity(0, 8192, {1, 0, 0, 0}) = 32 | |
mmap(0xc000000000, 65536, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc000000000 | |
munmap(0xc000000000, 65536) = 0 | |
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f41063b8000 | |
mmap(0xc820000000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc820000000 | |
mmap(0xc81fff8000, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc81fff8000 | |
mmap(0xc000000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc000000000 | |
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f41063a8000 |
NewerOlder