Skip to content

Commit 3b3ec5f

Browse files
committed
Tidy some of the bash scripts
1 parent d102a29 commit 3b3ec5f

3 files changed

Lines changed: 39 additions & 7 deletions

File tree

bin/benchmark-in-docker.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ required_tool docker
2626
required_tool hyperfine
2727

2828
# Pre-build the Docker image
29-
if [ -z "${SKIP_DOCKER_BUILD}" ]; then
29+
if [[ -z "${SKIP_DOCKER_BUILD}" ]]; then
3030
docker build --rm -t exercism/replace-this-with-the-track-slug-test-runner .
3131
else
3232
echo "Skipping docker build because SKIP_DOCKER_BUILD is set."
3333
fi
3434

3535
hyperfine \
36-
--parameter-list slug $(find tests -maxdepth 1 -mindepth 1 -type d -printf $'%f\n' | paste -sd ",") \
36+
--parameter-list slug "$(find tests -maxdepth 1 -mindepth 1 -type d -printf $'%f\n' | paste -sd ",")" \
3737
--prepare 'git clean -xdfq tests/{slug}' \
3838
'SKIP_DOCKER_BUILD=true bin/run-in-docker.sh {slug} tests/{slug} tests/{slug}'

bin/benchmark.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ required_tool() {
2222
required_tool hyperfine
2323

2424
hyperfine \
25-
--parameter-list slug $(find tests -maxdepth 1 -mindepth 1 -type d -printf $'%f\n' | paste -sd ",") \
25+
--parameter-list slug "$(find tests -maxdepth 1 -mindepth 1 -type d -printf $'%f\n' | paste -sd ",")" \
2626
--prepare 'git clean -xdfq tests/{slug}' \
2727
'bin/run.sh {slug} tests/{slug} tests/{slug}'

bin/bootstrap.sh

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ required_tool() {
2424
}
2525

2626
# If any required arguments is missing, print the usage and exit
27-
if [ -z "${LANGUAGE}" ] || [ -z "${SLUG}" ]; then
27+
if [[ -z "${LANGUAGE}" || -z "${SLUG}" ]]; then
2828
help_and_exit
2929
fi
3030

@@ -39,11 +39,13 @@ REPO_DIR=$(mktemp -d)
3939
cp -a . "${REPO_DIR}"
4040
cd "${REPO_DIR}" || die "Failed to cd to ${REPO_DIR}"
4141

42-
for file in $(git grep --files-with-matches replace-this-with-the-track-slug); do
42+
mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-slug)
43+
for file in "${files[@]}"; do
4344
sed -i "s/replace-this-with-the-track-slug/${SLUG}/g" "${file}"
4445
done
4546

46-
for file in $(git grep --files-with-matches replace-this-with-the-track-name); do
47+
mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-name)
48+
for file in "${files[@]}"; do
4749
sed -i "s/replace-this-with-the-track-name/${LANGUAGE}/g" "${file}"
4850
done
4951

@@ -71,7 +73,37 @@ gh api --method PUT "/orgs/${ORG}/actions/secrets/DOCKERHUB_PASSWORD/repositorie
7173
gh api --method PUT "/orgs/${ORG}/actions/secrets/DOCKERHUB_USERNAME/repositories/${REPO_ID}"
7274

7375
# Create ruleset for default branch
74-
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 -
76+
jq -n '
77+
{
78+
name: "Default branch",
79+
target: "branch",
80+
enforcement: "active",
81+
conditions: {
82+
ref_name: {
83+
include: ["~DEFAULT_BRANCH"],
84+
exclude:[]
85+
}
86+
},
87+
rules: [
88+
{
89+
type: "pull_request",
90+
parameters: {
91+
dismiss_stale_reviews_on_push: false,
92+
require_code_owner_review: true,
93+
require_last_push_approval: false,
94+
required_approving_review_count: 0,
95+
required_review_thread_resolution: false
96+
}
97+
}
98+
],
99+
"bypass_actors": [
100+
{
101+
"actor_id": 1,
102+
"actor_type": "OrganizationAdmin",
103+
"bypass_mode": "always"
104+
}
105+
]
106+
}' | gh api --method POST "/repos/${REPO}/rulesets" --input -
75107

76108
# Add topics
77109
gh api --method PUT "/repos/${REPO}/topics" -f "names[]=exercism-test-runner" -f "names[]=exercism-tooling"

0 commit comments

Comments
 (0)