Skip to content

Conversation

@artamonovkirill
Copy link
Contributor

Groovy 4

Changes

  • Groovy 4
  • Spock 2.3
  • A script to verify reference solutions work

Comments

  • I didn't find any backward-incompatible language features in Groovy 4 release notes, so it should be fine to temporarily have the test runner ahead of the local dependencies in the Groovy track. The PR to update the Gradle files will follow up shortly.
  • groovy-test-runner caches its dependencies via Maven and can be upgraded independently from the Gradle dependencies in the groovy repository.
  • This PR changes Groovy dependency from groovy-all to just groovy, but that should be fine since the exercises should depend on core language features, not on extra libraries (e.g., groovy-json or groovy-xml). At least the reference solutions do not - see run-reference-solution-tests-in-docker.sh script and the proof of work for more details.
  • Since run-reference-solution-tests-in-docker.sh relies on an external repository (groovy) checked out, I only ran it manually but omitted adding it to CI

Proof of work

./bin/run-reference-solution-tests-in-docker.sh
#0 building with "desktop-linux" instance using docker driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 746B done
#1 DONE 0.0s

#2 [internal] load metadata for docker.io/library/maven:3.8.3-jdk-11
#2 ...

#3 [auth] library/maven:pull token for registry-1.docker.io
#3 DONE 0.0s

#4 [internal] load metadata for docker.io/library/maven:3.8.3-jdk-11-slim
#4 DONE 1.4s

#2 [internal] load metadata for docker.io/library/maven:3.8.3-jdk-11
#2 DONE 1.4s

#5 [internal] load .dockerignore
#5 transferring context: 121B done
#5 DONE 0.0s

#6 [cache 1/5] FROM docker.io/library/maven:3.8.3-jdk-11@sha256:efaeca6b14ed6e05b2923416eebddd78c0e175a24580a29ca1d8a4c1ece196b2
#6 DONE 0.0s

#7 [stage-1 1/6] FROM docker.io/library/maven:3.8.3-jdk-11-slim@sha256:a4c3091b7de4b95fff1c947c11c35384e6e99cb09a79b8fcf5844eeea1de5f02
#7 DONE 0.0s

#8 [internal] load build context
#8 transferring context: 15.85kB 0.1s done
#8 DONE 0.1s

#9 [stage-1 2/6] WORKDIR /opt/test-runner
#9 CACHED

#10 [stage-1 3/6] RUN apt-get update &&     apt-get install -y jq &&     apt-get purge --auto-remove -y &&     apt-get clean &&     rm -rf /var/lib/apt/lists/*
#10 CACHED

#11 [cache 4/5] COPY pom.xml .
#11 CACHED

#12 [cache 3/5] COPY src/ src/
#12 CACHED

#13 [cache 2/5] WORKDIR /opt/exercise
#13 CACHED

#14 [cache 5/5] RUN mvn test dependency:go-offline -DexcludeReactor=false
#14 CACHED

#15 [stage-1 4/6] COPY . .
#15 DONE 0.1s

#16 [stage-1 5/6] COPY --from=cache /root/.m2 /root/.m2
#16 DONE 0.5s

#17 [stage-1 6/6] COPY --from=cache /opt/exercise/pom.xml /root/pom.xml
#17 DONE 0.0s

#18 exporting to image
#18 exporting layers 0.1s done
#18 writing image sha256:32452c3ebc175dd76b8aee442039ef47cca60b71fee3163393d0a97bad42ccc8 done
#18 naming to docker.io/exercism/groovy-test-runner done
#18 DONE 0.1s
rm: /Users/kirill/workspace/exercism/source/groovy-test-runner/tmp: No such file or directory
accumulate: testing...
accumulate: done
acronym: testing...
acronym: done
all-your-base: testing...
all-your-base: done
allergies: testing...
allergies: done
anagram: testing...
anagram: done
armstrong-numbers: testing...
armstrong-numbers: done
atbash-cipher: testing...
atbash-cipher: done
bank-account: testing...
bank-account: done
binary-search: testing...
binary-search: done
bob: testing...
bob: done
circular-buffer: testing...
circular-buffer: done
collatz-conjecture: testing...
collatz-conjecture: done
darts: testing...
darts: done
difference-of-squares: testing...
difference-of-squares: done
dnd-character: testing...
dnd-character: done
eliuds-eggs: testing...
eliuds-eggs: done
etl: testing...
etl: done
flatten-array: testing...
flatten-array: done
gigasecond: testing...
gigasecond: done
grains: testing...
grains: done
hamming: testing...
hamming: done
hello-world: testing...
hello-world: done
high-scores: testing...
high-scores: done
isbn-verifier: testing...
isbn-verifier: done
isogram: testing...
isogram: done
largest-series-product: testing...
largest-series-product: done
leap: testing...
leap: done
linked-list: testing...
cp: cannot stat '/solution/src/test/groovy/LinkedListSpec.groovy': No such file or directory
sed: can't read /solution/src/test/groovy/LinkedListSpec.groovy: No such file or directory
sed: can't read /solution/src/test/groovy/LinkedListSpec.groovy: No such file or directory
mv: cannot stat '/solution/src/test/groovy/LinkedListSpec.groovy.original': No such file or directory
linked-list: done
list-ops: testing...
list-ops: done
luhn: testing...
luhn: done
matching-brackets: testing...
matching-brackets: done
matrix: testing...
matrix: done
nth-prime: testing...
nth-prime: done
nucleotide-count: testing...
nucleotide-count: done
pangram: testing...
pangram: done
pascals-triangle: testing...
pascals-triangle: done
perfect-numbers: testing...
perfect-numbers: done
phone-number: testing...
phone-number: done
pig-latin: testing...
pig-latin: done
prime-factors: testing...
prime-factors: done
protein-translation: testing...
protein-translation: done
proverb: testing...
proverb: done
queen-attack: testing...
queen-attack: done
raindrops: testing...
raindrops: done
resistor-color: testing...
resistor-color: done
resistor-color-duo: testing...
resistor-color-duo: done
resistor-color-trio: testing...
resistor-color-trio: done
reverse-string: testing...
reverse-string: done
rna-transcription: testing...
rna-transcription: done
robot-name: testing...
robot-name: done
robot-simulator: testing...
robot-simulator: done
roman-numerals: testing...
roman-numerals: done
rotational-cipher: testing...
rotational-cipher: done
run-length-encoding: testing...
run-length-encoding: done
saddle-points: testing...
saddle-points: done
scrabble-score: testing...
scrabble-score: done
secret-handshake: testing...
secret-handshake: done
series: testing...
series: done
sieve: testing...
sieve: done
space-age: testing...
space-age: done
square-root: testing...
square-root: done
strain: testing...
strain: done
sum-of-multiples: testing...
sum-of-multiples: done
triangle: testing...
triangle: done
two-fer: testing...
two-fer: done
word-count: testing...
word-count: done
yacht: testing...
yacht: done
✅ All tests passed

- Groovy 4
- Spock 2.3
- A script to verify reference solutions work
@artamonovkirill artamonovkirill requested a review from a team as a code owner January 5, 2025 14:06
@github-actions
Copy link

github-actions bot commented Jan 5, 2025

Hello. Thanks for opening a PR on Exercism 🙂

We ask that all changes to Exercism are discussed on our Community Forum before being opened on GitHub. To enforce this, we automatically close all PRs that are submitted. That doesn't mean your PR is rejected but that we want the initial discussion about it to happen on our forum where a wide range of key contributors across the Exercism ecosystem can weigh in.

You can use this link to copy this into a new topic on the forum. If we decide the PR is appropriate, we'll reopen it and continue with it, so please don't delete your local branch.

If you're interested in learning more about this auto-responder, please read this blog post.


Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it.

@github-actions github-actions bot closed this Jan 5, 2025
@IsaacG IsaacG reopened this Jan 5, 2025

# Assumes exercism/groovy repository is checked out next to the exercism/groovy-test-runner repository.
# If the repository is checked out elsewhere, provide the path as the first argument.
groovy_repo_path=$(realpath "${1:-${PWD}/../groovy}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is realpath standard? I'm used to readlink -e

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the same command as the existing run-tests.sh: https://github.com/artamonovkirill/groovy-test-runner/blob/86676ee7822a6bb22b9a366887a8383bf4d10137/bin/run-tests.sh#L19

Reading this thread, readlink might have been more widely available in 2014, but I am not sure about now.

I'd opt for realpath for consistency.

Copy link
Contributor Author

@artamonovkirill artamonovkirill Jan 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

results_json="${exercise_tmp_dir}/output/results.json"
status=$(jq -r ".status" "${results_json}")
if [[ "${status}" != "pass" ]]; then
echo "💥 Test failed for ${exercise_slug}, check the output in ${results_json}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to run all the tests to get the full details vs abort at the first failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK to fail on the first one - at least for now, as it's easier implementation-wise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failures=()
for ...;
    if failed; then failures+=("${slug}"); fi
done 
if [[ "${failures}" ]]; then ...; exit 1; fi
exit 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, updated!

Use numbers comparison

Co-authored-by: Isaac Good <[email protected]>
exit 1
fi

echo "✅ All tests passed"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the reference solutions passing with Groovy 4?

Copy link
Contributor Author

@artamonovkirill artamonovkirill Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, at least on my PC (c)

  1. docker rmi -f $(docker images -a -q)
  2. docker system prune
  3. ./bin/run-reference-solution-tests-in-docker.sh output gist pulls Spock 2.3 and Groovy 4.0.24

Should we add the step to check reference solutions to the CI? However, we will need first to check out the exercism/groovy repository.
Or would someone be up to running the same ☝️ on their machine?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any of that is necessary. After this is merged, you'll probably want to update the GitHub CI workflows in the exercism/groovy repo, so we'll catch it there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the plan was to update the exercise/groovy to the same Groovy and Spock version next.

@glennj glennj merged commit 65dc93b into exercism:main Jan 7, 2025
1 check passed
@artamonovkirill
Copy link
Contributor Author

artamonovkirill commented Jan 7, 2025

FYI, the test runner still works on the website, as expected:

success on Hello World

Sweet. Looks like you've solved the exercise!

failed tests on Hello World
ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0,  <<< FAILURE! - in HelloWorldSpec
[ERROR] HelloWorldSpec.Say Hi!(Object)    <<< FAILURE!
org.spockframework.runtime.SpockComparisonFailure: 
Condition not satisfied:

new HelloWorld().hello() == expected
|                |       |  |
|                |       |  Hello, World!
|                |       false
|                |       1 difference (92imilarity)
|                |       Hello, World(?)
|                |       Hello, World(!)
|                Hello, World?
<HelloWorld@5829e4f4>

	at HelloWorldSpec.Say Hi!(HelloWorldSpec.groovy:8)

[ERROR] Failures: 
[ERROR] HelloWorldSpec.Say Hi!(Object)
[ERROR]   Run 1: HelloWorldSpec.Say Hi!:8 Condition not satisfied:

new HelloWorld().hello() == expected
|                |       |  |
|                |       |  Hello, World!
|                |       false
|                |       1 difference (92imilarity)
|                |       Hello, World(?)
|                |       Hello, World(!)
|                Hello, World?
<HelloWorld@5829e4f4>

[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

@artamonovkirill
Copy link
Contributor Author

Here's the one for exercism/groovy: exercism/groovy#468
Quite some changes due to bump of the Gradle wrapper version 😞

@glennj
Copy link
Contributor

glennj commented Jan 7, 2025

|                Hello, World?

LOL, so timid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants