Skip to content

Instantly share code, notes, and snippets.

View lox's full-sized avatar

Lachlan Donald lox

View GitHub Profile
@lox
lox / indicate.go
Created January 2, 2022 02:18
Thinking on an API for spinner/progress bar library
// Spinners and Progress bars are the same thing.
// They are assembled with a go template with some built in functions or templated strings
// for things like messages before and after.
// Render a spinner that looks like:
// ⡀ Loading blah... [3s]
spinner := indicate.New(context.Background(),
`{{ spinner "⠁⠂⠄⡀⢀⠠⠐⠈ " }} {{ template "message" }} [{{ elapsed }}]`).
WithDefaults(indicate.SpinnerDefaults).
@lox
lox / main.go
Created July 14, 2021 02:36
A utility for generating GitHub Access Tokens from a GitHub App
package main
import (
"bytes"
"crypto/rsa"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
@lox
lox / test.sh
Created July 30, 2020 10:41
Testing interpolation
echo "test"
@lox
lox / child.sh
Last active November 4, 2019 01:49
#!/bin/bash
set -euo pipefail
terminate(){
printf "Terminating child process $$ after signal."
exit 1
}
printf "Running $0, pid is %d, pgid is %d\n" "$$" "$(ps -o pgid= $$)"
@lox
lox / buildkite.yml
Created February 4, 2019 07:52
A pipeline with no checkout
steps:
- command: echo hello world!
#!/bin/bash
set -euo pipefail
measure() {
f=$1
n=$2
shift 2
echo wall,user,sys,rss > "$f"
for i in $(seq $n); do
[[ -d $i ]] && rm -rf $i
@lox
lox / README.md
Last active November 13, 2019 04:17
How Buildkite Environment is Created

I've done a bit of a deep dive into how we produce our env. The flow is slightly complicated as some environment comes from the shell that the agent runs in and some comes from buildkite.com and then some is generated each job.

For context, the code that generates the job environment is here: https://github.com/buildkite/agent/blob/2f3d6935996d45877071c01f7b19ae07db302d69/agent/job_runner.go#L307-L426

Paraphrased, the process is:

  • A build is triggered on buildkite.com, with user-provided environment (step or pipeline level) and bk specific env
  • Write out base job environment to an env file for future reference and set BUILDKITE_ENV_FILE
  • The agent job runner merges in it's env (overwriting anything set above, creating "protected" env)
@lox
lox / .buildkite.yml
Last active November 23, 2018 02:25
Test windows steps
steps:
- label: windows-steps
command: "echo hello"
plugins:
- docker#8baeb676321d59634ecaae938e83b13c17f447e0:
image: "microsoft/dotnet:latest"
agents:
queue: ${BUILDKITE_AGENT_META_DATA_QUEUE}
@lox
lox / README.md
Created November 1, 2018 22:04
Test disabling http2

Based on golang/go#13598, I should be able to disable the http2 client with:

GODEBUG=h2client=0 go run get.go
@lox
lox / pipeline.yml
Last active October 18, 2018 05:38
Example of docker plugin for windows
steps:
- command: echo hello world
agents:
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE:-default}"
plugins:
- "docker#d2c3221":
image: "microsoft/windowsservercore:ltsc2016"
debug: true