Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/benchmark-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
2 changes: 1 addition & 1 deletion bin/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
45 changes: 37 additions & 8 deletions bin/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -39,13 +39,11 @@ 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
sed -i "s/replace-this-with-the-track-slug/${SLUG}/g" "${file}"
done
mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-slug)
perl -pi -e "s/replace-this-with-the-track-slug/${SLUG}/g" "${files[@]}"

for file in $(git grep --files-with-matches replace-this-with-the-track-name); do
sed -i "s/replace-this-with-the-track-name/${LANGUAGE}/g" "${file}"
done
mapfile -t files < <(git grep --files-with-matches replace-this-with-the-track-name)
perl -pi -e "s/replace-this-with-the-track-name/${LANGUAGE}/g" "${files[@]}"

rm -f bin/bootstrap.sh
rm -rf .git
Expand All @@ -71,7 +69,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:[]}}, 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 -
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
}
}
],
"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"