Skip to content

Commit 35b04f4

Browse files
cmccandlessyawpitch
authored andcommitted
Fix hole in CI README check (#2132)
* generate READMEs with a hints file to verify up-to-date * regenerate READMEs that have hints.md
1 parent 2697358 commit 35b04f4

File tree

11 files changed

+22
-24
lines changed

11 files changed

+22
-24
lines changed

bin/check-readmes.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
SPEC="${1:-spec}"
4+
35
get_timestamp()
46
{
57
path="$1"
@@ -8,15 +10,19 @@ get_timestamp()
810

911
ret=0
1012
for exercise in $(ls -d exercises/*/); do
11-
meta_dir="${exercise}.meta"
12-
hints_file="${meta_dir}/HINTS.md"
13+
exercise="${exercise%/}"
14+
slug="$(basename "$exercise")"
15+
meta_dir="${exercise}/.meta"
16+
hints_file="${meta_dir}/hints.md"
17+
readme="${exercise}/README.md"
1318
if [ -f "$hints_file" ]; then
14-
hints_timestamp="$(get_timestamp "$hints_file")"
15-
readme_timestamp="$(get_timestamp "${exercise}README.md")"
16-
if [ "$hints_timestamp" -gt "$readme_timestamp" ]; then
17-
ret=1
18-
echo "$(basename "$exercise"): .meta/HINTS.md contents newer than README. Please regenerate README with configlet."
19+
bin/configlet generate -p "$SPEC" -o "${slug}" .
20+
if ! git diff --quiet "${readme}"; then
21+
echo "$slug: README is out-of-date. Please regenerate README with configlet."
22+
else
23+
echo "$slug ok"
1924
fi
25+
git checkout -- "${readme}"
2026
fi
2127
done
2228

exercises/collatz-conjecture/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Resulting in 9 steps. So for input n = 12, the return value would be 9.
3131
The Collatz Conjecture is only concerned with strictly positive integers, so your solution should raise a `ValueError` with a meaningful message if given 0 or a negative integer.
3232

3333

34-
3534
## Exception messages
3635

3736
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to

exercises/complex-numbers/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Assume the programming language you are using does not have an implementation of
3333
See [Emulating numeric types](https://docs.python.org/2/reference/datamodel.html#emulating-numeric-types) for help on operator overloading.
3434

3535

36-
3736
## Exception messages
3837

3938
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to

exercises/diffie-hellman/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ cryptographically strong random numbers that provide the greater security requir
5454
Since this is only an exercise, `random` is fine to use, but note that **it would be
5555
very insecure if actually used for cryptography.**
5656

57-
5857
## Exception messages
5958

6059
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to

exercises/dot-dsl/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
A [Domain Specific Language
44
(DSL)](https://en.wikipedia.org/wiki/Domain-specific_language) is a
5-
small language optimized for a specific domain. Since a DSL is
6-
targeted, it can greatly impact productivity/understanding by allowing the
5+
small language optimized for a specific domain. Since a DSL is
6+
targeted, it can greatly impact productivity/understanding by allowing the
77
writer to declare *what* they want rather than *how*.
88

99
One problem area where they are applied are complex customizations/configurations.
@@ -27,14 +27,14 @@ Write a Domain Specific Language similar to the Graphviz dot language.
2727

2828
Our DSL is similar to the Graphviz dot language in that our DSL will be used
2929
to create graph data structures. However, unlike the DOT Language, our DSL will
30-
be an internal DSL for use only in our language.
30+
be an internal DSL for use only in our language.
3131

3232
More information about the difference between internal and external DSLs can be
3333
found [here](https://martinfowler.com/bliki/DomainSpecificLanguage.html).
3434

3535
## Description of DSL
3636

37-
A graph, in this DSL, is an object of type `Graph`, taking a list of one
37+
A graph, in this DSL, is an object of type `Graph`, taking a list of one
3838
or more
3939

4040
+ attributes
@@ -48,7 +48,6 @@ The implementations of `Node` and `Edge` provided in `dot_dsl.py`.
4848
Observe the test cases in `dot_dsl_test.py` to understand the DSL's design.
4949

5050

51-
5251
## Exception messages
5352

5453
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to

exercises/error-handling/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class implements the following methods:
1919
- `do_something`, which may or may not throw an `Exception`.
2020

2121

22-
2322
## Exception messages
2423

2524
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to

exercises/matrix/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ And its columns:
4040
- 8, 3, 6
4141
- 7, 2, 7
4242

43-
In this exercise you're going to create a **class**. _Don't worry, it's not as complicated as you think!_
43+
In this exercise you're going to create a **class**. _Don't worry, it's not as complicated as you think!_
4444

45-
- [**A First Look at Classes**](https://docs.python.org/3/tutorial/classes.html#a-first-look-at-classes) from the Python 3 documentation.
46-
- [**How to Define a Class in Python**](https://realpython.com/python3-object-oriented-programming/#how-to-define-a-class-in-python) from the Real Python website.
45+
- [**A First Look at Classes**](https://docs.python.org/3/tutorial/classes.html#a-first-look-at-classes) from the Python 3 documentation.
46+
- [**How to Define a Class in Python**](https://realpython.com/python3-object-oriented-programming/#how-to-define-a-class-in-python) from the Real Python website.
4747
- [**Data Structures in Python**](https://docs.python.org/3/tutorial/datastructures.html) from the Python 3 documentation.
4848

4949

exercises/minesweeper/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ In this exercise you have to create some code that counts the number of
1010
mines adjacent to a given empty square and replaces that square with the
1111
count.
1212

13-
The board is a rectangle composed of blank space (' ') characters. A mine
13+
The board is a rectangle composed of blank space (' ') characters. A mine
1414
is represented by an asterisk ('\*') character.
1515

1616
If a given space has no adjacent mines at all, leave that square blank.
@@ -42,7 +42,6 @@ ValueError with a *meaningful* error message if the
4242
input turns out to be malformed.
4343

4444

45-
4645
## Exception messages
4746

4847
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to

exercises/ocr-numbers/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Is converted to "123,456,789"
8080

8181
## Hints
8282

83-
ocr.convert should validate its input and raise ValueErrors with meaningful error messages if necessary.
83+
Your converter should validate its input and raise a ValueError with a meaningful message if it receives a string that isn't a valid OCR number.
8484

8585

8686
## Exception messages

exercises/simple-cipher/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ Since this is only an exercise, `random` is fine to use, but note that **it woul
9696
very insecure if actually used for cryptography.**
9797

9898

99-
10099
## Exception messages
101100

102101
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to

0 commit comments

Comments
 (0)