Skip to content

Commit 71eddd9

Browse files
ErikSchierboomBartMasseyIMperiumXmstrangerdcr8898
authored
Reorder keys (#3)
* Format using prettier (exercism#1917) Format using prettier * updated description of anagrams exercise (exercism#1928) * updated description of anagrams * changed anagram description to be one-sentence-per-line * updated description of anagrams to use sets * Update Licence Give a look at the discussion in BR exercism#1930 * rational-numbers: test to reduce abs value (exercism#1938) * Change saddle point references to row, column (exercism#1948) * word-search: Add test case * Update exercises/word-search/canonical-data.json Agreed. Co-authored-by: Erik Schierboom <[email protected]> * meetup: improve descriptions by saying why each case is tested (exercism#1919) descriptions show whether a date is the first, last, or an arbitrary middle date of the week. This helps understand why certain cases are selected. Closes exercism#974 * word-search: Add cases checking for concatenation and wrapping The author of this commit thinks that concatenation is highly unlikely, but the wrapping might be useful to check in languages that allow negative indices. * `flatten-array` Add additional test cases (exercism#1953) * Add additional test cases to flatten-array * Update exercises/flatten-array/canonical-data.json Co-authored-by: Peter Tseng <[email protected]> Co-authored-by: BethanyG <[email protected]> Co-authored-by: Peter Tseng <[email protected]> * Fix bowling game copy (exercism#1955) Fixes exercism#1954 * Add action to format code (exercism#1941) * build(deps): bump DavidAnson/markdownlint-cli2-action (exercism#1952) Bumps [DavidAnson/markdownlint-cli2-action](https://github.com/DavidAnson/markdownlint-cli2-action) from 5.0.0 to 5.1.0. - [Release notes](https://github.com/DavidAnson/markdownlint-cli2-action/releases) - [Commits](DavidAnson/markdownlint-cli2-action@b3c3b40...744f913) --- updated-dependencies: - dependency-name: DavidAnson/markdownlint-cli2-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Reduced rational nr. should be in standard form. (exercism#1958) * Reduced rational should be in standard form. The current instructors fail to mention that a reduced rational number should always be rendered in standard form (without any negative value at the denominator). * remove superflous blank lines; fix wording * scale-generator: use flat and sharp symbols (exercism#1942) * Update configlet part in README (exercism#1949) Co-authored-by: ee7 <[email protected]> * phone number: only one problem per test input (exercism#1959) * [Phone Number] Only one problem per test input Because the area code is not allowed to start with 0 or 1, inputs designed to elicit other errors should not use area codes that start with either of those digits. * Respect immutability * Correct field name: s/comment/comments/ * Comments should contain a list. * Allow prettier to improve comments * book-store: reorder keys * darts: reorder keys * grade-school: reorder keys * hamming: reorder keys * high-scores: reorder keys * largest-series-product: reorder keys * list-ops: reorder keys * luhn: reorder keys * triangle: reorder keys * scale-generator: reorder keys * saddle-points: reorder keys * diffie-hellman: reorder keys * collatz-conjecture: reorder keys * anagram: reorder keys * accumulate: reorder keys * Add CI script to check correct order of keys Co-authored-by: Bart Massey <[email protected]> Co-authored-by: y8l <[email protected]> Co-authored-by: Ivan Ivanov <[email protected]> Co-authored-by: Damian C. Rossney <[email protected]> Co-authored-by: mariohuq <[email protected]> Co-authored-by: mariohuq <[email protected]> Co-authored-by: Peter Tseng <[email protected]> Co-authored-by: Peter Tseng <[email protected]> Co-authored-by: AH WEI <[email protected]> Co-authored-by: BethanyG <[email protected]> Co-authored-by: Cedd Burge <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Davide Alberto Molin <[email protected]> Co-authored-by: wolf99 <[email protected]> Co-authored-by: June <[email protected]> Co-authored-by: ee7 <[email protected]> Co-authored-by: Leah Hanson <[email protected]>
1 parent 87cd20f commit 71eddd9

File tree

79 files changed

+3599
-3006
lines changed

Some content is hidden

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

79 files changed

+3599
-3006
lines changed

.github/workflow-tests/immutability-check/canonical-data-changed-scenarios-after.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"uuid": "0f998f19-69ee-4c64-80ef-01b086feab80",
7070
"description": "Imaginary part of a number with real and imaginary part",
7171
"property": "imaginary",
72-
"input": {
72+
"input": {
7373
"z": [1, 2]
7474
},
7575
"expected": 2
@@ -331,7 +331,7 @@
331331
"uuid": "6d96d4c6-2edb-445b-94a2-7de6d4caaf60",
332332
"description": "Euler's identity/formula",
333333
"property": "exp",
334-
"input": {
334+
"input": {
335335
"z": [0, "pi"]
336336
},
337337
"expected": [-1, 0]

.github/workflow-tests/immutability-check/canonical-data-changed-scenarios-before.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"uuid": "0f998f19-69ee-4c64-80ef-01b086feab80",
7070
"description": "Imaginary part of a number with real and imaginary part",
7171
"property": "imaginary",
72-
"input": {
72+
"input": {
7373
"z": [1, 2]
7474
},
7575
"expected": 2
@@ -331,7 +331,7 @@
331331
"uuid": "6d96d4c6-2edb-445b-94a2-7de6d4caaf60",
332332
"description": "Euler's identity/formula",
333333
"property": "exp",
334-
"input": {
334+
"input": {
335335
"z": [0, "pi"]
336336
},
337337
"expected": [-1, 0]

.github/workflow-tests/immutability-check/canonical-data-deleted-case.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"uuid": "0f998f19-69ee-4c64-80ef-01b086feab80",
6060
"description": "Imaginary part of a number with real and imaginary part",
6161
"property": "imaginary",
62-
"input": {
62+
"input": {
6363
"z": [1, 2]
6464
},
6565
"expected": 2
@@ -321,7 +321,7 @@
321321
"uuid": "6d96d4c6-2edb-445b-94a2-7de6d4caaf60",
322322
"description": "Euler's identity/formula",
323323
"property": "exp",
324-
"input": {
324+
"input": {
325325
"z": [0, "pi"]
326326
},
327327
"expected": [-1, 0]

.github/workflow-tests/immutability-check/canonical-data-mutated-and-deleted.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"uuid": "0f998f19-69ee-4c64-80ef-01b086feab80",
6969
"description": "Imaginary part of a number with real and imaginary part",
7070
"property": "imaginary",
71-
"input": {
71+
"input": {
7272
"z": [1, 2]
7373
},
7474
"expected": 2
@@ -320,7 +320,7 @@
320320
"uuid": "6d96d4c6-2edb-445b-94a2-7de6d4caaf60",
321321
"description": "Euler's identity/formula",
322322
"property": "exp",
323-
"input": {
323+
"input": {
324324
"z": [0, "pi"]
325325
},
326326
"expected": [-1, 0]

.github/workflow-tests/immutability-check/canonical-data-mutated.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"uuid": "0f998f19-69ee-4c64-80ef-01b086feab80",
6969
"description": "Imaginary part of a number with real and imaginary part",
7070
"property": "imaginary",
71-
"input": {
71+
"input": {
7272
"z": [1, 2]
7373
},
7474
"expected": 2
@@ -330,7 +330,7 @@
330330
"uuid": "6d96d4c6-2edb-445b-94a2-7de6d4caaf60",
331331
"description": "Euler's identity/formula",
332332
"property": "exp",
333-
"input": {
333+
"input": {
334334
"z": [0, "pi"]
335335
},
336336
"expected": [-1, 0]

.github/workflow-tests/immutability-check/canonical-data-new-test.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"uuid": "0f998f19-69ee-4c64-80ef-01b086feab80",
7878
"description": "Imaginary part of a number with real and imaginary part",
7979
"property": "imaginary",
80-
"input": {
80+
"input": {
8181
"z": [1, 2]
8282
},
8383
"expected": 2
@@ -339,7 +339,7 @@
339339
"uuid": "6d96d4c6-2edb-445b-94a2-7de6d4caaf60",
340340
"description": "Euler's identity/formula",
341341
"property": "exp",
342-
"input": {
342+
"input": {
343343
"z": [0, "pi"]
344344
},
345345
"expected": [-1, 0]

.github/workflow-tests/immutability-check/canonical-data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"uuid": "0f998f19-69ee-4c64-80ef-01b086feab80",
6969
"description": "Imaginary part of a number with real and imaginary part",
7070
"property": "imaginary",
71-
"input": {
71+
"input": {
7272
"z": [1, 2]
7373
},
7474
"expected": 2
@@ -330,7 +330,7 @@
330330
"uuid": "6d96d4c6-2edb-445b-94a2-7de6d4caaf60",
331331
"description": "Euler's identity/formula",
332332
"property": "exp",
333-
"input": {
333+
"input": {
334334
"z": [0, "pi"]
335335
},
336336
"expected": [-1, 0]

.github/workflows/action-format.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Format
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
format:
9+
name: 'Format JSON'
10+
runs-on: ubuntu-latest
11+
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/format')
12+
steps:
13+
- name: 'Post acknowledgement that it will format code'
14+
continue-on-error: true # Never fail the build if this fails
15+
uses: actions/github-script@e3cbab99d3a9b271e1b79fc96d103a4a5534998c
16+
with:
17+
github-token: ${{ secrets.GITHUB_TOKEN }}
18+
script: |
19+
github.issues.createComment({
20+
issue_number: context.issue.number,
21+
owner: context.repo.owner,
22+
repo: context.repo.repo,
23+
body: 'The "Format code" action has started running.'
24+
})
25+
26+
- name: 'Download PR data'
27+
run: |
28+
PR_DATA="/tmp/pr.json"
29+
30+
jq -r ".issue.pull_request.url" "$GITHUB_EVENT_PATH" | \
31+
xargs curl --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -o "$PR_DATA" --url
32+
33+
- name: 'Check fork status'
34+
id: fork_status
35+
run: |
36+
IS_FORK="$(jq '.head.repo.fork' "/tmp/pr.json")"
37+
echo "::set-output name=fork::$IS_FORK"
38+
39+
- name: 'Setup SSH deploy key'
40+
if: steps.fork_status.outputs.fork == 'false'
41+
run: |
42+
mkdir ~/.ssh
43+
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519
44+
chmod 600 ~/.ssh/id_ed25519
45+
46+
- name: 'Checkout code'
47+
run: |
48+
PR_DATA="/tmp/pr.json"
49+
50+
HEAD_REF=$(jq -r ".head.ref" "$PR_DATA")
51+
52+
if [ ${{ steps.fork_status.outputs.fork }} == "false" ]; then
53+
echo "::debug::Setting up repo using SSH"
54+
HEAD_REPO=$(jq -r '.head.repo.ssh_url' "$PR_DATA")
55+
else
56+
echo "::debug::Setting up repo using HTTPS"
57+
HEAD_REPO=$(jq -r '.head.repo.clone_url | sub("https://"; "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@")' "$PR_DATA")
58+
fi
59+
60+
git clone $HEAD_REPO .
61+
git checkout -b "$HEAD_REF" "origin/$HEAD_REF"
62+
63+
- name: Use Node.js LTS (16.x)
64+
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561
65+
with:
66+
node-version: '16'
67+
68+
# https://github.com/actions/cache/blob/main/examples.md#node---yarn
69+
- name: Get yarn cache directory path
70+
id: yarn-cache-dir-path
71+
run: echo "::set-output name=dir::$(yarn cache dir)"
72+
73+
- name: Cache yarn
74+
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed
75+
id: yarn-cache
76+
with:
77+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
78+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
79+
restore-keys: |
80+
${{ runner.os }}-yarn-
81+
82+
- name: Install dependencies
83+
run: yarn install --pure-lockfile
84+
85+
- name: Format JSON files
86+
run: yarn format-json
87+
88+
- name: 'Commit formatted code'
89+
run: |
90+
# Check if there is nothing to commit (i.e. no formatting changes made)
91+
if [ -z "$(git status --porcelain)" ]; then
92+
echo "Code is already formatted correctly"
93+
exit 0
94+
fi
95+
96+
# Setup the git user (required to commit anything)
97+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
98+
git config --global user.name "github-actions[bot]"
99+
100+
# Commit the changes made by prettier
101+
git add .
102+
git commit -m "[CI] Format code"
103+
git push
104+
105+
- name: 'Post acknowledgement that it has formatted the code'
106+
continue-on-error: true # Never fail the build if this fails
107+
uses: actions/github-script@e3cbab99d3a9b271e1b79fc96d103a4a5534998c
108+
with:
109+
github-token: ${{ secrets.GITHUB_TOKEN }}
110+
script: |
111+
github.issues.createComment({
112+
issue_number: context.issue.number,
113+
owner: context.repo.owner,
114+
repo: context.repo.repo,
115+
body: 'The "Format code" action has finished running.'
116+
})
117+
118+
- name: 'Post reminder to trigger build manually'
119+
continue-on-error: true # Never fail the build if this fails
120+
if: steps.fork_status.outputs.fork == 'true'
121+
uses: actions/github-script@e3cbab99d3a9b271e1b79fc96d103a4a5534998c
122+
with:
123+
github-token: ${{ secrets.GITHUB_TOKEN }}
124+
script: |
125+
github.issues.createComment({
126+
issue_number: context.issue.number,
127+
owner: context.repo.owner,
128+
repo: context.repo.repo,
129+
body: 'For security reasons, `/format` does not trigger CI builds when the PR has been submitted from a fork. If checks were not passing due to code format, trigger a build to make the required checks pass, through one of the following ways:\n\n- Push an empty commit to this branch: `git commit --allow-empty -m "Trigger builds"`.\n- Close and reopen the PR.\n- Push a regular commit to this branch.'
130+
})

.github/workflows/ci.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,41 @@ jobs:
116116
117117
exit "$fail"
118118
119+
- name: Verify that all keys are in the correct order
120+
run: ./bin/check_key_order.rb
121+
119122
markdown-lint:
120123
name: Lint markdown files
121124
runs-on: ubuntu-latest
122125
steps:
123126
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
124127

125-
- uses: DavidAnson/markdownlint-cli2-action@b3c3b40b95c18bfa5363f6821764398c7149ad04
128+
- uses: DavidAnson/markdownlint-cli2-action@744f913a124058ee903768d3adb92a4847e5d132
126129
with:
127130
globs: |
128131
**/*.md
132+
133+
json-lint:
134+
name: Lint json files
135+
runs-on: ubuntu-latest
136+
steps:
137+
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
138+
139+
- name: Get yarn cache directory path
140+
id: yarn-cache-dir-path
141+
run: echo "::set-output name=dir::$(yarn cache dir)"
142+
143+
- name: Cache yarn
144+
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed
145+
id: yarn-cache
146+
with:
147+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
148+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
149+
restore-keys: |
150+
${{ runner.os }}-yarn-
151+
152+
- name: Install dependencies
153+
run: yarn install
154+
155+
- name: Verify that json files are formatted correctly
156+
run: yarn test-json-formatting

.prettierignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
exercises/allergies/canonical-data.json
2+
exercises/book-store/canonical-data.json
3+
exercises/bowling/canonical-data.json
4+
exercises/change/canonical-data.json
5+
exercises/connect/canonical-data.json
6+
exercises/diamond/canonical-data.json
7+
exercises/dominoes/canonical-data.json
8+
exercises/flatten-array/canonical-data.json
9+
exercises/forth/canonical-data.json
10+
exercises/go-counting/canonical-data.json
11+
exercises/grep/canonical-data.json
12+
exercises/house/canonical-data.json
13+
exercises/kindergarten-garden/canonical-data.json
14+
exercises/knapsack/canonical-data.json
15+
exercises/markdown/canonical-data.json
16+
exercises/minesweeper/canonical-data.json
17+
exercises/ocr-numbers/canonical-data.json
18+
exercises/pascals-triangle/canonical-data.json
19+
exercises/poker/canonical-data.json
20+
exercises/pov/canonical-data.json
21+
exercises/pythagorean-triplet/canonical-data.json
22+
exercises/rectangles/canonical-data.json
23+
exercises/reverse-string/canonical-data.json
24+
exercises/roman-numerals/canonical-data.json
25+
exercises/rotational-cipher/canonical-data.json
26+
exercises/saddle-points/canonical-data.json
27+
exercises/scale-generator/canonical-data.json
28+
exercises/sieve/canonical-data.json
29+
exercises/spiral-matrix/canonical-data.json
30+
exercises/tournament/canonical-data.json
31+
exercises/transpose/canonical-data.json
32+
exercises/variable-length-quantity/canonical-data.json
33+
exercises/word-search/canonical-data.json

CONTRIBUTING.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ This guide covers several common scenarios pertaining to **improving the languag
2222
* [Track Anatomy](#track-anatomy)
2323
* [Starting a New Track](#starting-a-new-track)
2424
* [Beta-Testing a Language Track](#beta-testing-a-language-track)
25-
* [Useful Tidbits](#useful-tidbits)
25+
* [Useful Tidbits](#useful-tidbits)
2626
* [Pull Request Guidelines](#pull-request-guidelines)
2727
* [Anatomy of an Exercise](#anatomy-of-an-exercise)
2828
* [Track configuration file (config.json)](#track-configuration-file)
2929
* [Track-Level Linting With Configlet](#track-level-linting-with-configlet)
3030
* [Git Basics](#git-basics)
3131
* [Improving Consistency By Extracting Shared Test Data](#improving-consistency-by-extracting-shared-test-data)
32+
* [Formatting](#formatting)
3233

3334
## We Will Gladly Help You Help Us
3435

@@ -301,6 +302,18 @@ TODO: add more sections:
301302

302303
We are maintaining this section, since many open issues link to it.
303304

305+
## Formatting
306+
307+
This repository uses [prettier][prettier] to automatically format its JSON files.
308+
If you've added or modified a JSON file, you can format it using:
309+
310+
```shell
311+
yarn install
312+
yarn format-json
313+
```
314+
315+
Note: if you use VS Code as your editor, you can install the [prettier plugin][prettier-vs-code] to automatically handle formatting for you.
316+
304317
[contributing]: https://exercism.org/contributing
305318
[support-chat]: https://gitter.im/exercism/support
306319
[exercism-issues]: https://github.com/exercism/exercism/issues
@@ -322,3 +335,5 @@ We are maintaining this section, since many open issues link to it.
322335
[git-basics]: https://github.com/exercism/legacy-docs/blob/main/contributing/git-basics.md
323336
[improve-exercise-metadata]: https://github.com/exercism/legacy-docs/blob/main/you-can-help/improve-exercise-metadata.md
324337
[legacy-docs]: https://github.com/exercism/legacy-docs
338+
[prettier]: https://prettier.io/
339+
[prettier-vs-code]: https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2019 Exercism
3+
Copyright (c) 2014, 2019, 2021 Exercism
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)