diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..81f799e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,37 @@ +name: Tests + +on: + push: + branches: [main] + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # the declared floor in README.md, and a current release + python-version: ["3.8", "3.13"] + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + + - name: Compile both modules + run: python -m py_compile src/collide.py src/ideaCollisionGenerator.py + + - name: Run the test suite + run: python -m unittest discover -s tests -v + + # the suite patches every prompt, so the real stdin path documented in + # README.md is exercised here instead + - name: Run the program end to end + run: | + printf 'k%s\n' 1 2 3 4 5 6 7 8 9 10 > fixture.txt + printf 'idea %s\n' 1 2 3 4 5 >> fixture.txt + python src/collide.py < fixture.txt + written=$(cat ideas/ideas-*.txt | wc -l) + test "$written" -eq 5 diff --git a/README.md b/README.md index 8a258fd..0bd03ff 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,11 @@ python3 -m unittest discover -s tests Every prompt is patched, so no test waits on real input. +[`.github/workflows/tests.yml`](.github/workflows/tests.yml) runs the same +commands on every push to `main` and on every pull request, against Python 3.8 +and 3.13: `py_compile` over both modules, the test suite, and one full run of +the program with a 15-line fixture on stdin. + ## License See [LICENSE](LICENSE).