Skip to content

Commit

Permalink
Add test generator (#1722)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
senekor authored Sep 13, 2023
1 parent 9800892 commit 5ebc065
Show file tree
Hide file tree
Showing 87 changed files with 2,385 additions and 1,402 deletions.
10 changes: 0 additions & 10 deletions .editorconfig

This file was deleted.

112 changes: 26 additions & 86 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,19 @@ name: CI
on:
push:
branches:
- main
- main
pull_request:
workflow_dispatch:
schedule:
# Weekly.
- cron: "0 0 * * 0"

jobs:
ensure-conventions:
name: Ensure conventions are followed
runs-on: ubuntu-latest

steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

- name: Ensure tool names are snake cased
run: ./bin/lint_tool_file_names.sh

- name: Ensure src/lib.rs files exist
run: ./_test/ensure_lib_src_rs_exist.sh

- name: Count ignores
run: ./_test/count_ignores.sh

- name: Check UUIDs
run: ./_test/check_uuids.sh

- name: Verify exercise difficulties
run: ./_test/verify_exercise_difficulties.sh

- name: Check exercises for authors
run: ./_test/check_exercises_for_authors.sh

- name: Ensure relevant files do not have trailing whitespace
run: ./bin/lint_trailing_spaces.sh

configlet:
name: configlet lint
runs-on: ubuntu-latest

steps:
# Checks out default branch locally so that it is available to the scripts.
- name: Checkout main
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
ref: main

# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

Expand All @@ -68,10 +31,6 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout main
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
ref: main
- name: Checkout code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

Expand All @@ -80,35 +39,24 @@ jobs:

# stolen from https://raw.githubusercontent.com/exercism/github-actions/main/.github/workflows/shellcheck.yml
shellcheck:
name: shellcheck internal tooling lint
name: Run shellcheck on scripts
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

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

compilation:
name: Check compilation
runs-on: ubuntu-latest

strategy:
# Allows running the job multiple times with different configurations
matrix:
rust: ["stable", "beta"]
deny_warnings: ['', '1']

steps:
# Checks out main locally so that it is available to the scripts.
- name: Checkout main
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
ref: main

# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

Expand All @@ -117,19 +65,31 @@ jobs:
with:
toolchain: ${{ matrix.rust }}

# run scripts as steps
- name: Check exercises
env:
DENYWARNINGS: ${{ matrix.deny_warnings }}
run: ./_test/check_exercises.sh
continue-on-error: ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}
DENYWARNINGS: "1"
run: ./bin/check_exercises.sh

- name: Ensure stubs compile
env:
DENYWARNINGS: ${{ matrix.deny_warnings }}
run: ./_test/ensure_stubs_compile.sh
continue-on-error: ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}
DENYWARNINGS: "1"
run: ./bin/ensure_stubs_compile.sh

tests:
name: Run repository tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

- name: Setup toolchain
uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e
with:
toolchain: stable

- name: Run tests
run: cd rust-tooling && cargo test

rustformat:
name: Check Rust Formatting
Expand All @@ -144,11 +104,8 @@ jobs:
with:
toolchain: stable

- name: Rust Format Version
run: rustfmt --version

- name: Format
run: bin/format_exercises
run: ./bin/format_exercises.sh

- name: Diff
run: |
Expand All @@ -166,11 +123,6 @@ jobs:
rust: ["stable", "beta"]

steps:
- name: Checkout main
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
ref: main

- name: Checkout code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

Expand All @@ -179,34 +131,22 @@ jobs:
with:
toolchain: ${{ matrix.rust }}

# Clippy already installed on Stable, but not Beta.
# So, we must install here.
- name: Install Clippy
run: rustup component add clippy

- name: Clippy tests
env:
CLIPPY: true
run: ./_test/check_exercises.sh
run: ./bin/check_exercises.sh

- name: Clippy stubs
env:
CLIPPY: true
run: ./_test/ensure_stubs_compile.sh
run: ./bin/ensure_stubs_compile.sh

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

steps:
# Checks out main locally so that it is available to the scripts.
- name: Checkout main
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
ref: main

# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

Expand All @@ -217,5 +157,5 @@ jobs:

- name: Check exercises
env:
BENCHMARK: '1'
run: ./_test/check_exercises.sh
BENCHMARK: "1"
run: ./bin/check_exercises.sh
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
.DS_Store
**/target
tmp
bin/configlet
bin/configlet.exe
bin/exercise
bin/exercise.exe
bin/generator-utils/ngram
bin/generator-utils/escape_double_quotes
/bin/configlet
exercises/*/*/Cargo.lock
exercises/*/*/clippy.log
canonical_data.json
.vscode
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "problem-specifications"]
path = problem-specifications
url = [email protected]:exercism/problem-specifications
Loading

0 comments on commit 5ebc065

Please sign in to comment.