Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions .github/workflows/order-of-practice-exercises.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Ensure practice exercise order

on:
pull_request:
branches:
- main

permissions:
contents: read

jobs:
call-gha-workflow:
name: check
uses: exercism/github-actions/.github/workflows/sorted.yml@main
with:
ordering: ".difficulty, .lowercase_name"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The following system dependencies are required:
- [`bash` shell][gnu-bash].
- PHP V8.4+ CLI.
- An active Internet connection for installing required tools / composer packages.
- [`jq`][jq], if you change the difficulty or add a practice exercise.

Run the following command to get started with this project:

Expand Down Expand Up @@ -90,6 +91,8 @@ contribution/generator/bin/console app:create-tests '<slug>'
composer lint:fix
```

Run `bin/order-exercises.sh` when you set the exercise difficulty to a sensible value to order the exercises on the website accordingly.

[exercism-configlet]: https://exercism.org/docs/building/configlet
[exercism-docs]: https://exercism.org/docs
[exercism-track-home]: https://exercism.org/docs/tracks/php
Expand All @@ -98,3 +101,4 @@ composer lint:fix
[gnu-bash]: https://www.gnu.org/software/bash/
[local-file-phpcs-config]: phpcs.xml
[psr-12]: https://www.php-fig.org/psr/psr-12
[jq]: https://jqlang.org/
11 changes: 11 additions & 0 deletions bin/order-exercises.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# matches ".difficulty, .lowercase_name" in .github/workflows/order-of-practice-exercises.yml

jq '
.exercises.practice |= (
map(if .slug == "hello-world" then .difficulty = -1 else . end)
| sort_by(.difficulty, (.name|ascii_downcase))
| .[0].difficulty = 1
)
' config.json > config.sorted && mv config.sorted config.json
Loading
Loading