Skip to content

Commit 686cddb

Browse files
committed
Merge remote-tracking branch 'origin/camicia-exercice' into camicia-exercice
2 parents a170168 + ce2d56d commit 686cddb

732 files changed

Lines changed: 3660 additions & 2123 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/check-deprecated-exercises.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ name: Deprecated
22

33
on:
44
pull_request:
5+
paths:
6+
- "exercises/**"
7+
push:
8+
branches:
9+
- main
10+
workflow_dispatch:
511

612
jobs:
713
test-deprecated:
814
name: Check for deprecated exercises
915
runs-on: ubuntu-24.04
1016
steps:
11-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
1218
with:
1319
fetch-depth: 0
1420
- name: Test deprecated exercises using test-deprecated-exercises

.github/workflows/java.yml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ jobs:
1515
name: Check if tests compile cleanly with starter sources
1616
runs-on: ubuntu-24.04
1717
steps:
18-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
19-
- name: Set up JDK 1.17
20-
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165
18+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
19+
- name: Set up JDK 21
20+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654
2121
with:
22-
java-version: 17
22+
java-version: 21
2323
distribution: "temurin"
2424
- name: Check if tests compile cleanly with starter sources
2525
run: ./gradlew compileStarterTestJava --continue
@@ -29,11 +29,11 @@ jobs:
2929
name: Lint Java files using Checkstyle
3030
runs-on: ubuntu-24.04
3131
steps:
32-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
33-
- name: Set up JDK 1.17
34-
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165
32+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
33+
- name: Set up JDK 21
34+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654
3535
with:
36-
java-version: 17
36+
java-version: 21
3737
distribution: "temurin"
3838
- name: Run checkstyle
3939
run: ./gradlew check --exclude-task test --continue
@@ -44,11 +44,23 @@ jobs:
4444
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
4545
runs-on: ubuntu-24.04
4646
steps:
47-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
47+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
4848
- name: Test all exercises using java-test-runner
4949
run: bin/test-with-test-runner
50+
- name: Print summary
51+
run: |
52+
if [ -f exercises/build/summary.txt ]; then
53+
echo "===== TEST SUMMARY ====="
54+
cat exercises/build/summary.txt
55+
echo "========================"
56+
else
57+
echo "===== ALL TESTS PASSED ====="
58+
echo "No summary file was generated."
59+
echo "============================="
60+
fi
61+
if: always()
5062
- name: Archive test results
51-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
63+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
5264
with:
5365
name: test-results
5466
path: exercises/**/build/results.json
@@ -59,13 +71,25 @@ jobs:
5971
if: github.event_name == 'pull_request'
6072
runs-on: ubuntu-24.04
6173
steps:
62-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
74+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
6375
with:
6476
fetch-depth: 0
6577
- name: Test changed exercises using java-test-runner
6678
run: bin/test-changed-exercise
79+
- name: Print summary
80+
run: |
81+
if [ -f exercises/build/summary.txt ]; then
82+
echo "===== TEST SUMMARY ====="
83+
cat exercises/build/summary.txt
84+
echo "========================"
85+
else
86+
echo "===== ALL TESTS PASSED ====="
87+
echo "No summary file was generated."
88+
echo "============================="
89+
fi
90+
if: always()
6791
- name: Archive test results
68-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
92+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
6993
with:
7094
name: test-results
7195
path: |

.github/workflows/markdown.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ jobs:
1717
name: Lint Markdown files
1818
runs-on: ubuntu-24.04
1919
steps:
20-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
20+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
2121
- name: Lint markdown
22-
uses: DavidAnson/markdownlint-cli2-action@992badcdf24e3b8eb7e87ff9287fe931bcb00c6e
22+
uses: DavidAnson/markdownlint-cli2-action@ce4853d43830c74c1753b39f3cf40f71c2031eb9

bin/test-changed-exercise

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ echo "Changed exercises detected:"
3535
echo "$changed_exercises"
3636
echo "----------------------------------------"
3737

38+
summary_dir="exercises/build"
39+
summary_file="${summary_dir}/summary.txt"
40+
mkdir -p "$summary_dir"
41+
3842
# Run tests
43+
exit_code=0
3944
for dir in $changed_exercises; do
4045
slug=$(basename "$dir")
4146

@@ -47,8 +52,27 @@ for dir in $changed_exercises; do
4752
mkdir -p "$(dirname "$results_path")"
4853

4954
if [[ $dir == exercises/practice/* ]]; then
50-
./exercises/gradlew -p exercises ":practice:$slug:test" 2>&1 | tee "$results_path"
55+
./exercises/gradlew -p exercises ":practice:$slug:test" 2>&1 | tee "$results_path" || true
5156
elif [[ $dir == exercises/concept/* ]]; then
52-
./exercises/gradlew -p exercises ":concept:$slug:test" 2>&1 | tee "$results_path"
57+
./exercises/gradlew -p exercises ":concept:$slug:test" 2>&1 | tee "$results_path" || true
58+
fi
59+
60+
# Detect failure
61+
if grep -q "FAILED" "$results_path"; then
62+
exit_code=1
63+
64+
# Determine practice/slug or concept/slug
65+
relative_path=$(echo "$dir" | sed 's|^exercises/||')
66+
67+
# Create summary.txt with header only on first failure
68+
if [ ! -f "$summary_file" ]; then
69+
echo "The following exercises have test failures or test errors:" > "$summary_file"
70+
fi
71+
72+
# Append the correct path (practice/slug or concept/slug)
73+
echo "$relative_path" >> "$summary_file"
5374
fi
75+
5476
done
77+
78+
exit $exit_code

bin/test-with-test-runner

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ docker pull exercism/java-test-runner
1212

1313
exit_code=0
1414

15+
summary_dir="exercises/build"
16+
summary_file="${summary_dir}/summary.txt"
17+
mkdir -p "$summary_dir"
18+
1519
function run_test_runner() {
1620
local slug=$1
1721
local solution_dir=$2
@@ -56,6 +60,18 @@ function verify_exercise() {
5660

5761
if [[ $(jq -r '.status' "${results_file}") != "pass" ]]; then
5862
echo "${slug}: ${implementation_file_key} solution did not pass the tests"
63+
64+
# Determine practice/slug or concept/slug
65+
local relative_path=$(echo "$dir" | sed -E 's|.*/exercises/||')
66+
67+
# Create summary.txt with header only on first failure
68+
if [ ! -f "$summary_file" ]; then
69+
echo "The following exercises have test failures or test errors:" > "$summary_file"
70+
fi
71+
72+
# Append the correct path (practice/slug or concept/slug)
73+
echo "$relative_path" >> "$summary_file"
74+
5975
exit_code=1
6076
fi
6177

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"blurb": "There are several classes in Java to work with dates and time.",
3-
"authors": ["sanderploegsma"],
4-
"contributors": []
3+
"authors": [
4+
"sanderploegsma"
5+
],
6+
"contributors": [
7+
"kahgoh"
8+
]
59
}

concepts/datetime/about.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,18 @@ printer.format(date);
118118
// => "December 3, 2007"
119119
```
120120

121+
A [locale][locale] can also be specified when creating the custom format to format and parse for different regions:
122+
123+
```java
124+
DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.FRENCH).format(date);
125+
// => décembre 3, 2007
126+
127+
DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.of("pt")).format(date);
128+
// => dezembro 3, 2007
129+
```
130+
121131
[iso-8601]: https://en.wikipedia.org/wiki/ISO_8601
122132
[localdate-docs]: https://docs.oracle.com/javase/8/docs/api/java/time/LocalDate.html
123133
[localdatetime-docs]: https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html
134+
[locale]: https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html
124135
[datetimeformatter-docs]: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html

concepts/datetime/introduction.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,14 @@ printer.format(date);
8686
// => "December 3, 2007"
8787
```
8888

89+
A locale can also be specified when creating the custom format to format and parse for different regions:
90+
91+
```java
92+
DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.FRENCH).format(date);
93+
// => décembre 3, 2007
94+
95+
DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.of("pt")).format(date);
96+
// => dezembro 3, 2007
97+
```
98+
8999
[iso-8601]: https://en.wikipedia.org/wiki/ISO_8601

config.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,20 @@
12111211
],
12121212
"difficulty": 6
12131213
},
1214+
{
1215+
"slug": "baffling-birthdays",
1216+
"name": "Baffling Birthdays",
1217+
"uuid": "b534049a-5920-4906-9091-0fa6d81a3636",
1218+
"practices": [],
1219+
"prerequisites": [
1220+
"for-loops",
1221+
"lists",
1222+
"sets",
1223+
"randomness",
1224+
"datetime"
1225+
],
1226+
"difficulty": 6
1227+
},
12141228
{
12151229
"slug": "bank-account",
12161230
"name": "Bank Account",

exercises/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ subprojects {
7878

7979
// configuration of the linter
8080
checkstyle {
81-
toolVersion '10.7.0'
82-
configFile file("checkstyle.xml")
81+
toolVersion = '10.7.0'
82+
configFile = file("$rootDir/checkstyle.xml")
8383
sourceSets = [project.sourceSets.main, project.sourceSets.test]
8484
}
8585

0 commit comments

Comments
 (0)