Repository navigation
675 mirror - #17
675 mirror#17Droid-An wants to merge 24 commits into
Conversation
Fix expected output: change 'with' to 'wIth' in sed exercise instructions
* Expected output now in expected folder * Github action which runs after validation, when Needs Review * Script that can be run to test locally before push * Split number sys qs into automatable/manualy checkable --------- Co-authored-by: l <l>
* Add a shebang because `-v` is a bash-ism not present in whatever my default shell is on macOS. * Remove `--quiet` from `cmp` - macOS's `cmp` doesn't support it.
* Trigger on added files - Cowsay involves writing brand new files * Hide previous comments * Fix completed -> complete * Clean up output a little
So a trainee has to convert the hex into a number before considering how this might look as colours. Ideally to improve lead into the idea of that % of bytes used can create the colour mix. Same could be said for the grey question needing more suggestion of how to calculate a colour mix (somehow hinting or leading to the idea of proportion of bytes used). Suggestions welcome for whether this fixes a misunderstanding or not, or if it can be improved.
Some trainees are doing a bit less than I was expecting when originally setting this. Not to be merged util the current cohort have completed Module-Tools.
…d through functions as arguments - also fixed an if boolean
| if: steps.test-individual-shell-tools.outputs.attempted == 'y' || steps.test-jq.outputs.attempted == 'y' || steps.test-shell-pipelines.outputs.attempted == 'y' || steps.test-number-systems.outputs.attempted == 'y' || steps.test-implement-cowsay.outputs.attempted == 'y' | ||
| env: |
There was a problem hiding this comment.
In the new test_sdc_tasks job, the same or very similar long boolean expressions are repeated in multiple if: conditions (for example, the list of steps.*.outputs.attempted checks in make output comment and fail if not complete, and the list of steps.*.outputs.complete checks in add appropriate labels).
This isn’t a functional bug, but it does mean that whenever you add or remove a task (e.g. another directory to test), you’d need to remember to update several separate if: expressions in exactly the same way. That’s often how inconsistencies creep in over time.
Would it be possible to centralise the notion of "any task attempted" and "any task complete" using a single step whose output you reuse, or by grouping these conditions in one place (for example via a small helper step that sets a combined output flag)? That way, adding a new task would only require updating one location, and the job-level conditions would stay in sync automatically.
To "like" or "dislike" this comment, please follow this link
| if [[ "$1" == "individual-shell-tools" ]]; then | ||
| cd individual-shell-tools | ||
| pass=0 | ||
| total=0 | ||
| for directory in */; do | ||
| cd $directory | ||
| if [ "$directory" == "helper-files/" ]; then | ||
| cd .. | ||
| continue | ||
| fi | ||
| for exercise in *.sh; do | ||
| total=$(($total+1)) | ||
| ./$exercise > ../../test.tmp | ||
| cmp ../../test.tmp ../../expect/individual-shell-tools/$directory$exercise | ||
| if [ $? -eq 0 ]; then | ||
| pass=$(($pass+1)) | ||
| else | ||
| if [[ "$exercise" == *"stretch"* && $(stat -c%s ../../test.tmp) == "0" ]]; then | ||
| # Stretch task not attempted, ignoring" | ||
| total=$(($total-1)) | ||
| else | ||
| echo "Failed $directory$exercise, please check" >> ../../testoutput.txt | ||
| fi | ||
| fi | ||
| done | ||
| cd .. | ||
| done | ||
| cd .. | ||
| rm test.tmp | ||
| echo "You passed $pass/$total tasks." >> testoutput.txt | ||
| if [ -v GITHUB_OUTPUT ]; then | ||
| echo "attempted=y" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| if [ $pass -ge $total ]; then | ||
| echo "This task is complete!" >> testoutput.txt | ||
| if [ -v GITHUB_OUTPUT ]; then | ||
| echo "complete=y" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| fi | ||
| cat testoutput.txt |
There was a problem hiding this comment.
Several branches of this script follow a very similar pattern: change into a task directory, loop over exercises, run each exercise to test.tmp, cmp against an expect file, maintain pass/total counters, and finally print a summary and set GITHUB_OUTPUT flags. Variants of this appear in the individual-shell-tools, shell-pipelines, and jq sections, and you also repeat rm test.tmp logic in multiple places.
When you have this kind of structural repetition, it becomes harder to keep behaviour consistent if you later tweak the testing logic (for example, if you change how you report failures or how you handle temporary files). You’d then need to apply the same change in several places and it’s easy for one branch to drift.
Could you imagine extracting the common “run command list, compare to expect files, track pass/total, update outputs” behaviour into a reusable function (or at least a single shared block) that takes the base directories as parameters? That would let each case just describe what to test, and the shared code would handle the mechanics consistently for all three task types.
To "like" or "dislike" this comment, please follow this link
| # This test file will be automatically run when you submit a pull request | ||
| # You should not modify this file | ||
| # You can run this file using ./test-sdc.sh task-directory-name to check your output |
There was a problem hiding this comment.
These top-of-file comments are all describing exactly what the script already does: it’s a bash script that will be run on PRs, shouldn’t be modified, and can be run with an argument. Because the behaviour is quite obvious from the shebang, filename and the ./test-sdc.sh task-directory-name usage, the comments don’t really add extra understanding.
When you add comments like this, it can be worth asking yourself: would a future reader be confused without this, or could they infer it from the code and context? If the answer is “they can already see it”, the comment might just add noise and become something that can go out of date later (for example, if someone ever changes how it’s invoked but forgets to update the comment).
How might you decide which of these high-level remarks are genuinely useful context (e.g. a one-line note that this file is run in CI) and which ones could be omitted because the code or filename already states the same thing?
To "like" or "dislike" this comment, please follow this link
|
The CYF AI review has left comments. It will only review a PR one time. When you have addressed these comments, please request review again and a volunteer will take a look. |
Learners, PR Template
Self checklist
Task code
Replace this line with the Task code (e.g. CYF-0000).
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer. You must remove this section if you have no questions.