From 3b3ec5f6238ee3f3e1c06be58bf76a3c128b08a8 Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Thu, 25 Sep 2025 11:26:46 -0700 Subject: [PATCH 1/7] Tidy some of the bash scripts --- bin/benchmark-in-docker.sh | 4 ++-- bin/benchmark.sh | 2 +- bin/bootstrap.sh | 40 ++++++++++++++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/bin/benchmark-in-docker.sh b/bin/benchmark-in-docker.sh index bd245a0..46429ce 100755 --- a/bin/benchmark-in-docker.sh +++ b/bin/benchmark-in-docker.sh @@ -26,13 +26,13 @@ required_tool docker required_tool hyperfine # Pre-build the Docker image -if [ -z "${SKIP_DOCKER_BUILD}" ]; then +if [[ -z "${SKIP_DOCKER_BUILD}" ]]; then docker build --rm -t exercism/replace-this-with-the-track-slug-test-runner . else echo "Skipping docker build because SKIP_DOCKER_BUILD is set." fi hyperfine \ - --parameter-list slug $(find tests -maxdepth 1 -mindepth 1 -type d -printf $'%f\n' | paste -sd ",") \ + --parameter-list slug "$(find tests -maxdepth 1 -mindepth 1 -type d -printf $'%f\n' | paste -sd ",")" \ --prepare 'git clean -xdfq tests/{slug}' \ 'SKIP_DOCKER_BUILD=true bin/run-in-docker.sh {slug} tests/{slug} tests/{slug}' diff --git a/bin/benchmark.sh b/bin/benchmark.sh index 55ec7ce..56866ba 100755 --- a/bin/benchmark.sh +++ b/bin/benchmark.sh @@ -22,6 +22,6 @@ required_tool() { required_tool hyperfine hyperfine \ - --parameter-list slug $(find tests -maxdepth 1 -mindepth 1 -type d -printf $'%f\n' | paste -sd ",") \ + --parameter-list slug "$(find tests -maxdepth 1 -mindepth 1 -type d -printf $'%f\n' | paste -sd ",")" \ --prepare 'git clean -xdfq tests/{slug}' \ 'bin/run.sh {slug} tests/{slug} tests/{slug}' diff --git a/bin/bootstrap.sh b/bin/bootstrap.sh index cd8134f..8639b91 100755 --- a/bin/bootstrap.sh +++ b/bin/bootstrap.sh @@ -24,7 +24,7 @@ required_tool() { } # If any required arguments is missing, print the usage and exit -if [ -z "${LANGUAGE}" ] || [ -z "${SLUG}" ]; then +if [[ -z "${LANGUAGE}" || -z "${SLUG}" ]]; then help_and_exit fi @@ -39,11 +39,13 @@ REPO_DIR=$(mktemp -d) cp -a . "${REPO_DIR}" cd "${REPO_DIR}" || die "Failed to cd to ${REPO_DIR}" -for file in $(git grep --files-with-matches replace-this-with-the-track-slug); do +mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-slug) +for file in "${files[@]}"; do sed -i "s/replace-this-with-the-track-slug/${SLUG}/g" "${file}" done -for file in $(git grep --files-with-matches replace-this-with-the-track-name); do +mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-name) +for file in "${files[@]}"; do sed -i "s/replace-this-with-the-track-name/${LANGUAGE}/g" "${file}" done @@ -71,7 +73,37 @@ gh api --method PUT "/orgs/${ORG}/actions/secrets/DOCKERHUB_PASSWORD/repositorie gh api --method PUT "/orgs/${ORG}/actions/secrets/DOCKERHUB_USERNAME/repositories/${REPO_ID}" # Create ruleset for default branch -jq -n '{name: "Default branch", target: "branch", enforcement: "active", conditions: {ref_name: {include: ["~DEFAULT_BRANCH"], exclude:[]}}, rules:[{type: "pull_request", parameters: {dismiss_stale_reviews_on_push: false, require_code_owner_review: true,require_last_push_approval: false, required_approving_review_count: 0, required_review_thread_resolution: false}}], "bypass_actors":[{"actor_id": 1, "actor_type": "OrganizationAdmin", "bypass_mode": "always"}]}' | gh api --method POST "/repos/${REPO}/rulesets" --input - +jq -n ' + { + name: "Default branch", + target: "branch", + enforcement: "active", + conditions: { + ref_name: { + include: ["~DEFAULT_BRANCH"], + exclude:[] + } + }, + rules: [ + { + type: "pull_request", + parameters: { + dismiss_stale_reviews_on_push: false, + require_code_owner_review: true, + require_last_push_approval: false, + required_approving_review_count: 0, + required_review_thread_resolution: false + } + } + ], + "bypass_actors": [ + { + "actor_id": 1, + "actor_type": "OrganizationAdmin", + "bypass_mode": "always" + } + ] + }' | gh api --method POST "/repos/${REPO}/rulesets" --input - # Add topics gh api --method PUT "/repos/${REPO}/topics" -f "names[]=exercism-test-runner" -f "names[]=exercism-tooling" From fae760ddd055cff403e6690ad9a54921390b60cf Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Thu, 25 Sep 2025 12:25:18 -0700 Subject: [PATCH 2/7] Update bin/bootstrap.sh Co-authored-by: Glenn Jackman --- bin/bootstrap.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/bootstrap.sh b/bin/bootstrap.sh index 8639b91..aa7fbbb 100755 --- a/bin/bootstrap.sh +++ b/bin/bootstrap.sh @@ -40,9 +40,7 @@ cp -a . "${REPO_DIR}" cd "${REPO_DIR}" || die "Failed to cd to ${REPO_DIR}" mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-slug) -for file in "${files[@]}"; do - sed -i "s/replace-this-with-the-track-slug/${SLUG}/g" "${file}" -done +sed -i "s/replace-this-with-the-track-slug/${SLUG}/g" "${files[@]}" mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-name) for file in "${files[@]}"; do From 83be2e4343574486185b4f73bfc32550c039c64e Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Thu, 25 Sep 2025 12:31:53 -0700 Subject: [PATCH 3/7] Use a variable for the JSON content --- bin/bootstrap.sh | 61 ++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/bin/bootstrap.sh b/bin/bootstrap.sh index aa7fbbb..bc6401a 100755 --- a/bin/bootstrap.sh +++ b/bin/bootstrap.sh @@ -71,37 +71,38 @@ gh api --method PUT "/orgs/${ORG}/actions/secrets/DOCKERHUB_PASSWORD/repositorie gh api --method PUT "/orgs/${ORG}/actions/secrets/DOCKERHUB_USERNAME/repositories/${REPO_ID}" # Create ruleset for default branch -jq -n ' - { - name: "Default branch", - target: "branch", - enforcement: "active", - conditions: { - ref_name: { - include: ["~DEFAULT_BRANCH"], - exclude:[] +ruleset=$(jq -cn ' +{ + name: "Default branch", + target: "branch", + enforcement: "active", + conditions: { + ref_name: { + include: ["~DEFAULT_BRANCH"], + exclude:[] + } + }, + rules: [ + { + type: "pull_request", + parameters: { + dismiss_stale_reviews_on_push: false, + require_code_owner_review: true, + require_last_push_approval: false, + required_approving_review_count: 0, + required_review_thread_resolution: false } - }, - rules: [ - { - type: "pull_request", - parameters: { - dismiss_stale_reviews_on_push: false, - require_code_owner_review: true, - require_last_push_approval: false, - required_approving_review_count: 0, - required_review_thread_resolution: false - } - } - ], - "bypass_actors": [ - { - "actor_id": 1, - "actor_type": "OrganizationAdmin", - "bypass_mode": "always" - } - ] - }' | gh api --method POST "/repos/${REPO}/rulesets" --input - + } + ], + "bypass_actors": [ + { + "actor_id": 1, + "actor_type": "OrganizationAdmin", + "bypass_mode": "always" + } + ] +}') +gh api --method POST "/repos/${REPO}/rulesets" --input - <<< "$ruleset" # Add topics gh api --method PUT "/repos/${REPO}/topics" -f "names[]=exercism-test-runner" -f "names[]=exercism-tooling" From 75e954421f6047e526f76a57c4762706346b9303 Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Thu, 25 Sep 2025 23:35:20 -0700 Subject: [PATCH 4/7] Invoke sed once with all the files --- bin/bootstrap.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/bootstrap.sh b/bin/bootstrap.sh index bc6401a..8c85a27 100755 --- a/bin/bootstrap.sh +++ b/bin/bootstrap.sh @@ -43,9 +43,7 @@ mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-s sed -i "s/replace-this-with-the-track-slug/${SLUG}/g" "${files[@]}" mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-name) -for file in "${files[@]}"; do - sed -i "s/replace-this-with-the-track-name/${LANGUAGE}/g" "${file}" -done +sed -i "s/replace-this-with-the-track-name/${LANGUAGE}/g" "${files[@]}" rm -f bin/bootstrap.sh rm -rf .git From a2d2d2545160fd9fb5ac3e26a691fb598d5891e6 Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Fri, 3 Oct 2025 10:09:31 -0700 Subject: [PATCH 5/7] Replace sed with perl for file edits --- bin/bootstrap.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/bootstrap.sh b/bin/bootstrap.sh index 8c85a27..da8249a 100755 --- a/bin/bootstrap.sh +++ b/bin/bootstrap.sh @@ -40,10 +40,10 @@ cp -a . "${REPO_DIR}" cd "${REPO_DIR}" || die "Failed to cd to ${REPO_DIR}" mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-slug) -sed -i "s/replace-this-with-the-track-slug/${SLUG}/g" "${files[@]}" +perl -pi -e "s/replace-this-with-the-track-slug/${SLUG}/g" "${files[@]}" mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-name) -sed -i "s/replace-this-with-the-track-name/${LANGUAGE}/g" "${files[@]}" +perl -pi -e "s/replace-this-with-the-track-name/${LANGUAGE}/g" "${files[@]}" rm -f bin/bootstrap.sh rm -rf .git From 1a621097cc8e12d834c006ea3dd21b0a6887620c Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Thu, 9 Oct 2025 14:37:13 -0700 Subject: [PATCH 6/7] Update bin/bootstrap.sh --- bin/bootstrap.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/bootstrap.sh b/bin/bootstrap.sh index da8249a..3204726 100755 --- a/bin/bootstrap.sh +++ b/bin/bootstrap.sh @@ -23,6 +23,12 @@ required_tool() { die "$1 is required but not installed. Please install it and make sure it's in your PATH." } +if (( "${BASH_VERSINFO[0]}${BASH_VERSINFO[1]}" < 44 )); then + echo "This script requires bash version 4.4 at minimum." >&2 + echo "You can install a modern bash from Homebrew - https://brew.sh" >&2 + exit 1 +fi + # If any required arguments is missing, print the usage and exit if [[ -z "${LANGUAGE}" || -z "${SLUG}" ]]; then help_and_exit From c2bc02190a0dbd12c510e83ea862fcbdea7e9d05 Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Sun, 12 Oct 2025 11:48:12 +0100 Subject: [PATCH 7/7] Update bin/bootstrap.sh Co-authored-by: Erik Schierboom --- bin/bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/bootstrap.sh b/bin/bootstrap.sh index 3204726..613d4b5 100755 --- a/bin/bootstrap.sh +++ b/bin/bootstrap.sh @@ -25,7 +25,7 @@ required_tool() { if (( "${BASH_VERSINFO[0]}${BASH_VERSINFO[1]}" < 44 )); then echo "This script requires bash version 4.4 at minimum." >&2 - echo "You can install a modern bash from Homebrew - https://brew.sh" >&2 + echo "You can install a modern bash from Homebrew: brew install bash" >&2 exit 1 fi