diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 632f36c9..132503c0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,23 +36,34 @@ jobs: - name: Run markdown lint run: ./bin/lint_markdown.sh - + + # stolen from https://raw.githubusercontent.com/exercism/github-actions/main/.github/workflows/shellcheck.yml + shellcheck: + name: Run shellcheck on scripts + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + + - name: Run shellcheck + uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 + build: name: Check build runs-on: ubuntu-22.04 - + steps: - name: Checkout code uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - + - name: Fetch origin/main run: git fetch --depth=1 origin main - + - name: Getting scarb uses: software-mansion/setup-scarb@v1 with: scarb-version: "2.6.3" - + - name: Verify all exercises env: DENYWARNINGS: "1" @@ -61,11 +72,11 @@ jobs: format: name: Check Cairo formatting runs-on: ubuntu-22.04 - + steps: - name: Checkout code uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - + - name: Getting scarb uses: software-mansion/setup-scarb@v1 with: diff --git a/bin/format_exercises.sh b/bin/format_exercises.sh index 8720c82a..94c65d43 100755 --- a/bin/format_exercises.sh +++ b/bin/format_exercises.sh @@ -8,32 +8,42 @@ repo=$(git rev-parse --show-toplevel) # traverse either concept or practice exercise # directory and format Cairo files format_exercises() { - exercises_path="$repo/exercises/$1" + exercises_path="$repo/exercises/$1/*" source_file_name="$2" - for exercise_dir in "$exercises_path"/*; do - cd "$exercise_dir" + + for exercise_dir in $exercises_path; do + cd "$exercise_dir" || exit 1 + + exercise=$(basename "$exercise_dir") + + # scarb fmt cannot currently format individual files, so we have to + # temporarily move the solution files into the Cairo package, where + # 'scarb fmt' can format it as well + tmp_file=$(mktemp "./src/tmp.XXXXXXXXXXX.cairo") + config_file="$exercise_dir/.meta/config.json" if jq --exit-status '.custom?."allowed-to-not-compile"?' "$config_file"; then - exercise=$(basename "$exercise_dir") echo "$exercise's stub is allowed to not compile" # exit the subshell successfully to continue # to the next exercise directory exit 0 fi - # scarb fmt cannot currently format individual files, so we have to - # temporarily move the solution files into the Cairo package, where - # 'scarb fmt' can format it as well - tmp_file=$(mktemp "./src/tmp.XXXXXXXXXXX.cairo") - file_name=".meta/$source_file_name.cairo" - if [ -f "$file_name" ]; then - cp "$file_name" "$tmp_file" + + solution_file=".meta/$source_file_name.cairo" + if [ -z "$solution_file" ]; then + echo "Could not find solution file for $exercise" + exit 1 fi + + # move the solution file into the package + cp "$solution_file" "$tmp_file" + scarb fmt + # move the solution file back - if [ -f "$file_name" ]; then - cp "$tmp_file" "$file_name" - fi - rm $tmp_file + cp "$tmp_file" "$solution_file" + + rm "$tmp_file" done } diff --git a/bin/lint_markdown.sh b/bin/lint_markdown.sh index e6be7aa5..278d2c7e 100755 --- a/bin/lint_markdown.sh +++ b/bin/lint_markdown.sh @@ -1,10 +1,7 @@ #!/usr/bin/env bash set -eo pipefail -markdownlint_cli_args="$1" - npx markdownlint-cli2 \ - $markdownlint_cli_args \ docs/*.md \ concepts/**/*.md \ exercises/**/*.md diff --git a/bin/verify-exercises b/bin/verify-exercises index 936db1cc..0d7d0898 100755 --- a/bin/verify-exercises +++ b/bin/verify-exercises @@ -2,18 +2,6 @@ # Synopsis: # Test the track's exercises. -# -# At a minimum, this file must check if the example/exemplar solution of each -# Practice/Concept Exercise passes the exercise's tests. -# -# To check this, you usually have to (temporarily) replace the exercise's solution files -# with its exemplar/example files. -# -# If your track uses skipped tests, make sure to (temporarily) enable these tests -# before running the tests. -# -# The path to the solution/example/exemplar files can be found in the exercise's -# .meta/config.json file, or possibly inferred from the exercise's directory name. # Example: verify all exercises # ./bin/verify-exercises @@ -25,38 +13,39 @@ repo=$(git rev-parse --show-toplevel) lib_cairo="./src/lib.cairo" +slug="${1:-*}" + verify_exercise() { - exercises_path="$repo/exercises/$1" + exercises_path="$repo/exercises/$1/$slug" source_file_name="$2" tmp_file=$(mktemp) - - for exercise_dir in "$exercises_path"/*; do - if [ -z $exercise_dir ]; then + trap 'rm $tmp_file' EXIT INT TERM + + for exercise_dir in $exercises_path; do + if [ -z "$exercise_dir" ]; then continue fi - - slug=$(basename "$exercise_dir") - echo "Checking $slug exercise..." - - cd "$exercise_dir" - + + exercise=$(basename "$exercise_dir") + echo "Checking $exercise exercise..." + + cd "$exercise_dir" || exit 1 + solution_file=".meta/$source_file_name.cairo" if [ -z "$solution_file" ]; then - echo "Could not find solution for $1" + echo "Could not find solution file for $exercise" exit 1 fi - + # since we're testing the solution, we need to temporarily replace # the exercise's solution files with its exemplar/example files cp "$lib_cairo" "$tmp_file" cp "$solution_file" "$lib_cairo" - + scarb cairo-test - + cp "$tmp_file" "$lib_cairo" done - - rm $tmp_file } # https://github.com/exercism/docs/blob/main/anatomy/tracks/concept-exercises.md#file-exemplar-implementation diff --git a/config.json b/config.json index fd6c9669..aa9eeec6 100644 --- a/config.json +++ b/config.json @@ -77,6 +77,16 @@ ], "prerequisites": [], "difficulty": 1 + }, + { + "slug": "lucians-luscious-lasagna", + "name": "lucians-luscious-lasagna", + "uuid": "8302f8de-14d7-45dd-9a65-812bc1ed5464", + "practices": [ + "functions" + ], + "prerequisites": [], + "difficulty": 1 } ] }, diff --git a/docs/ABOUT.md b/docs/ABOUT.md index c12f6b41..eacb151c 100644 --- a/docs/ABOUT.md +++ b/docs/ABOUT.md @@ -6,6 +6,7 @@ scalable [dApps][dapps] with the power of [validity proofs][zkp]. [cairo]: https://www.cairo-lang.org/ [dapps]: https://en.wikipedia.org/wiki/Decentralized_application [zkp]: https://en.wikipedia.org/wiki/Zero-knowledge_proof +