Skip to content

Instantly share code, notes, and snippets.

View schlagelk's full-sized avatar
🏕️

Kenny schlagelk

🏕️
  • Denver, CO
View GitHub Profile
@schlagelk
schlagelk / get-failed-tests.sh
Last active July 14, 2021 15:34
Fetches failed tests for a CircleCI workflow when rerunning said workflow from failed. This is done by using the current commit hash and checking for existing failed tests at said hash. Results are joined by a `,` so they can be easily passed into `xcodebuild -only-testing`. Requires jq
# Set a limit, helps with system outtages and can help avoid passing in a very long list of failed test to xcodebuild which would have the opposite effect
CCI_FAILED_TESTS_RERUN_LIMIT=11;
# $CIRCLECI_API_TOKEN is a CircleCI API token you presumably set in the project environment variables
if [[ -n "$CIRCLECI_API_TOKEN" && -n "$CIRCLE_SHA1" && -n "$CIRCLE_WORKFLOW_ID" ]]; then
pipeline_url="https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID"
echo "🤹🏼‍♂️ Fetching pipeline for $CIRCLE_WORKFLOW_ID"
pipeline=$(
curl -H "Circle-Token: $CIRCLECI_API_TOKEN" "$pipeline_url" | jq ' { pipeline_id: .pipeline_id, slug: .project_slug } '
@schlagelk
schlagelk / swibang
Last active November 16, 2022 08:26
A Git hook written in Swift using NLP to enforce commit message formatting. Checks if the first word of a message is a verb and has an uppercased first letter. chmod +x swibang and then mv to .git/hooks/commit-msg in your repo. Requires Xcode/Command Line tools, and just for fun
#!/usr/bin/env xcrun swift
import NaturalLanguage
let str = try! String(contentsOfFile: CommandLine.arguments[1]).trimmingCharacters(in: .whitespacesAndNewlines)
print("Analyzing commit message: '\(str)'")
if !str.first!.isUppercase {
print("\u{001B}[0;31mUppercase the first word of your commit message bro wtf")
exit(1)