Skip to content

Commit 5ebc065

Browse files
authored
Add test generator (#1722)
* cleanup dev tooling * move all scripts into `bin/` * turn several scripts into Rust tests: * `check_exercises_for_authors.sh` * `count_ignores.sh` * `verify_exercise_difficulty.sh` * `lint_tool_file_names.sh` * `lint_trailing_spaces.sh` * remove several scripts: * `check_uuids.sh`: `configlet lint` covers that already * `ensure_lib_src_rs_exists.sh`: this is not an issue if exercise stubs are generated * `clean_topics_vs_practices.py`: applies undocumented standards (max 10 practice exercises per topic) * `fetch_canonical_data`: we now have the submodule for this * cleanup documentation * remove generic instructions about WSL * merge `CONTRIBUTING.md` and `maintaining.md` * move contributing docs in `README.md` to `CONTRIBUTING.md` * outsource instructions for making good PRs * outsource instructions for installing Rust * steal beautiful `REAMDE.md` from Python track * apply conventions and guidelines in a couple places where the new Rust tests found deficiencies * replace Bash-based exercise generation with Rust-based one (deleting the related `util/` Rust crates) * can be used to sync with problem-specifications too * uses the Tera templating engine for customizable test generation inspired by the python track using Jinja for this purpose * apply test generation to acronym exercise to validate MVP
1 parent 9800892 commit 5ebc065

File tree

87 files changed

+2385
-1402
lines changed

Some content is hidden

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

87 files changed

+2385
-1402
lines changed

.editorconfig

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 26 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,19 @@ name: CI
44
on:
55
push:
66
branches:
7-
- main
7+
- main
88
pull_request:
99
workflow_dispatch:
1010
schedule:
1111
# Weekly.
1212
- cron: "0 0 * * 0"
1313

1414
jobs:
15-
ensure-conventions:
16-
name: Ensure conventions are followed
17-
runs-on: ubuntu-latest
18-
19-
steps:
20-
# Checks out a copy of your repository on the ubuntu-latest machine
21-
- name: Checkout code
22-
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
23-
24-
- name: Ensure tool names are snake cased
25-
run: ./bin/lint_tool_file_names.sh
26-
27-
- name: Ensure src/lib.rs files exist
28-
run: ./_test/ensure_lib_src_rs_exist.sh
29-
30-
- name: Count ignores
31-
run: ./_test/count_ignores.sh
32-
33-
- name: Check UUIDs
34-
run: ./_test/check_uuids.sh
35-
36-
- name: Verify exercise difficulties
37-
run: ./_test/verify_exercise_difficulties.sh
38-
39-
- name: Check exercises for authors
40-
run: ./_test/check_exercises_for_authors.sh
41-
42-
- name: Ensure relevant files do not have trailing whitespace
43-
run: ./bin/lint_trailing_spaces.sh
44-
4515
configlet:
4616
name: configlet lint
4717
runs-on: ubuntu-latest
4818

4919
steps:
50-
# Checks out default branch locally so that it is available to the scripts.
51-
- name: Checkout main
52-
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
53-
with:
54-
ref: main
55-
56-
# Checks out a copy of your repository on the ubuntu-latest machine
5720
- name: Checkout code
5821
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
5922

@@ -68,10 +31,6 @@ jobs:
6831
runs-on: ubuntu-latest
6932

7033
steps:
71-
- name: Checkout main
72-
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
73-
with:
74-
ref: main
7534
- name: Checkout code
7635
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
7736

@@ -80,35 +39,24 @@ jobs:
8039

8140
# stolen from https://raw.githubusercontent.com/exercism/github-actions/main/.github/workflows/shellcheck.yml
8241
shellcheck:
83-
name: shellcheck internal tooling lint
42+
name: Run shellcheck on scripts
8443
runs-on: ubuntu-latest
8544
steps:
8645
- name: Checkout
8746
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
8847

8948
- name: Run shellcheck
9049
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # v2.0.0
91-
env:
92-
SHELLCHECK_OPTS: -x -s bash -e SC2001 --norc
9350

9451
compilation:
9552
name: Check compilation
9653
runs-on: ubuntu-latest
9754

9855
strategy:
99-
# Allows running the job multiple times with different configurations
10056
matrix:
10157
rust: ["stable", "beta"]
102-
deny_warnings: ['', '1']
10358

10459
steps:
105-
# Checks out main locally so that it is available to the scripts.
106-
- name: Checkout main
107-
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
108-
with:
109-
ref: main
110-
111-
# Checks out a copy of your repository on the ubuntu-latest machine
11260
- name: Checkout code
11361
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
11462

@@ -117,19 +65,31 @@ jobs:
11765
with:
11866
toolchain: ${{ matrix.rust }}
11967

120-
# run scripts as steps
12168
- name: Check exercises
12269
env:
123-
DENYWARNINGS: ${{ matrix.deny_warnings }}
124-
run: ./_test/check_exercises.sh
125-
continue-on-error: ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}
70+
DENYWARNINGS: "1"
71+
run: ./bin/check_exercises.sh
12672

12773
- name: Ensure stubs compile
12874
env:
129-
DENYWARNINGS: ${{ matrix.deny_warnings }}
130-
run: ./_test/ensure_stubs_compile.sh
131-
continue-on-error: ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}
75+
DENYWARNINGS: "1"
76+
run: ./bin/ensure_stubs_compile.sh
77+
78+
tests:
79+
name: Run repository tests
80+
runs-on: ubuntu-latest
81+
82+
steps:
83+
- name: Checkout code
84+
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
85+
86+
- name: Setup toolchain
87+
uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e
88+
with:
89+
toolchain: stable
13290

91+
- name: Run tests
92+
run: cd rust-tooling && cargo test
13393

13494
rustformat:
13595
name: Check Rust Formatting
@@ -144,11 +104,8 @@ jobs:
144104
with:
145105
toolchain: stable
146106

147-
- name: Rust Format Version
148-
run: rustfmt --version
149-
150107
- name: Format
151-
run: bin/format_exercises
108+
run: ./bin/format_exercises.sh
152109

153110
- name: Diff
154111
run: |
@@ -166,11 +123,6 @@ jobs:
166123
rust: ["stable", "beta"]
167124

168125
steps:
169-
- name: Checkout main
170-
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
171-
with:
172-
ref: main
173-
174126
- name: Checkout code
175127
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
176128

@@ -179,34 +131,22 @@ jobs:
179131
with:
180132
toolchain: ${{ matrix.rust }}
181133

182-
# Clippy already installed on Stable, but not Beta.
183-
# So, we must install here.
184-
- name: Install Clippy
185-
run: rustup component add clippy
186-
187134
- name: Clippy tests
188135
env:
189136
CLIPPY: true
190-
run: ./_test/check_exercises.sh
137+
run: ./bin/check_exercises.sh
191138

192139
- name: Clippy stubs
193140
env:
194141
CLIPPY: true
195-
run: ./_test/ensure_stubs_compile.sh
142+
run: ./bin/ensure_stubs_compile.sh
196143

197144
nightly-compilation:
198145
name: Check exercises on nightly (benchmark enabled)
199146
runs-on: ubuntu-latest
200147
continue-on-error: true # It's okay if the nightly job fails
201148

202149
steps:
203-
# Checks out main locally so that it is available to the scripts.
204-
- name: Checkout main
205-
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
206-
with:
207-
ref: main
208-
209-
# Checks out a copy of your repository on the ubuntu-latest machine
210150
- name: Checkout code
211151
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
212152

@@ -217,5 +157,5 @@ jobs:
217157

218158
- name: Check exercises
219159
env:
220-
BENCHMARK: '1'
221-
run: ./_test/check_exercises.sh
160+
BENCHMARK: "1"
161+
run: ./bin/check_exercises.sh

.gitignore

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
.DS_Store
44
**/target
55
tmp
6-
bin/configlet
7-
bin/configlet.exe
8-
bin/exercise
9-
bin/exercise.exe
10-
bin/generator-utils/ngram
11-
bin/generator-utils/escape_double_quotes
6+
/bin/configlet
127
exercises/*/*/Cargo.lock
138
exercises/*/*/clippy.log
14-
canonical_data.json
159
.vscode

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "problem-specifications"]
2+
path = problem-specifications
3+
url = [email protected]:exercism/problem-specifications

0 commit comments

Comments
 (0)