-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup Hello World exercise #3
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: GDScript / Lint | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | ||
|
||
- name: Setup gdtoolkit | ||
uses: Scony/godot-gdscript-toolkit@09af1747fd66629af601b1f14d1ac24203358686 | ||
|
||
- name: Lint | ||
run: gdlint exercises |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,41 @@ | ||
#!/usr/bin/env bash | ||
|
||
# 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. | ||
temp_dir_base=$(mktemp -d) | ||
echo $(godot --version) | ||
|
||
# Example: | ||
# ./bin/test | ||
run_test() { | ||
slug=$(basename $1) | ||
temp_dir=${temp_dir_base}/${slug} | ||
mkdir -p ${temp_dir} | ||
# Copy relevant files to the temp directory (replace solution with example) | ||
solution_file_name="$(jq -r '.files.solution[0]' $1/.meta/config.json)" | ||
test_file="$1/$(jq -r '.files.test[0]' $1/.meta/config.json)" | ||
example_file="$1/$(jq -r '.files.example[0]' $1/.meta/config.json)" | ||
cp ${test_file} ${temp_dir} | ||
cp ${example_file} "${temp_dir}/${solution_file_name}" | ||
# Run the tests | ||
(cd /opt/test-runner && bin/run.sh $slug $temp_dir $temp_dir) || exit 1 | ||
# Check status | ||
test_status="$(jq -r '.status' $temp_dir/results.json)" | ||
if [ "$test_status" != "pass" ]; then | ||
echo "Tests for $slug have failed:" | ||
cat $temp_dir/results.json | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Verify the Concept Exercises | ||
for concept_exercise_dir in ./exercises/concept/*/; do | ||
if [ -d $concept_exercise_dir ]; then | ||
echo "Checking $(basename "${concept_exercise_dir}") exercise..." | ||
# TODO: run command to verify that the exemplar solution passes the tests | ||
run_test $concept_exercise_dir | ||
fi | ||
done | ||
|
||
# Verify the Practice Exercises | ||
for practice_exercise_dir in ./exercises/practice/*/; do | ||
if [ -d $practice_exercise_dir ]; then | ||
echo "Checking $(basename "${practice_exercise_dir}") exercise..." | ||
# TODO: run command to verify that the example solution passes the tests | ||
run_test $practice_exercise_dir | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Instructions | ||
|
||
The classical introductory exercise. | ||
Just say "Hello, World!". | ||
|
||
["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment. | ||
|
||
The objectives are simple: | ||
|
||
- Modify the provided code so that it produces the string "Hello, World!". | ||
- Run the test suite and make sure that it succeeds. | ||
- Submit your solution and check it at the website. | ||
|
||
If everything goes well, you will be ready to fetch your first real exercise. | ||
|
||
[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"authors": [ | ||
"pfertyk" | ||
], | ||
"contributors": [ | ||
"BNAndras" | ||
], | ||
"files": { | ||
"solution": [ | ||
"hello_world.gd" | ||
], | ||
"test": [ | ||
"hello_world_test.gd" | ||
], | ||
"example": [ | ||
".meta/example.gd" | ||
] | ||
}, | ||
"blurb": "The classical introductory exercise. Just say \"Hello, World!\".", | ||
"source": "This is an exercise to introduce users to using Exercism", | ||
"source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
func hello(): | ||
return "Hello, World!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# This is an auto-generated file. | ||
# | ||
# Regenerating this file via `configlet sync` will: | ||
# - Recreate every `description` key/value pair | ||
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications | ||
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) | ||
# - Preserve any other key/value pair | ||
# | ||
# As user-added comments (using the # character) will be removed when this file | ||
# is regenerated, comments can be added via a `comment` key. | ||
|
||
[af9ffe10-dc13-42d8-a742-e7bdafac449d] | ||
description = "Say Hi!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
func hello(): | ||
return "Goodbye, Mars!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
func test_hello_world(solution_script): | ||
return ["Hello, World!", solution_script.hello()] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpick but the indent seems larger here than in hello_world.gd so one of them probably needs to be updated to match the other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I've missed this 👍 Since Godot editor uses tabs by default, I think we should use them too (consistently, in all files). I've already changed the files :)
Side note: I think that Godot will accept both types of indentation, as long as they are consistent within a file, but there is no need to confuse GDScript learners :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I think you just need to ping Erik to take a final look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be good to choose a formatter / linter if available to make sure everything is consistent between contributors and PRs. https://github.com/Scony/godot-gdscript-toolkit seems promising since it has both. There's a GitHub Action for static analysis, but we could also use the CI for checking if a PR is well-formatted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a new workflow with that toolkit. It does detect some errors (e.g. an unnecessary
return
) but it doesn't detect things like mixed indent (tabs vs spaces). Nevertheless, I think it's a good idea to have the linter already configured, as it might get better in the future, and it already helps a bit. Thanks for this suggestion! ;)