Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up PR validation #6

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/lint-test-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will install Python dependencies, run tests and lint.
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Lint and Test Packages

on:
push:
branches: [ "main" ]
Comment on lines +7 to +8

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary. Nobody will be checking these post-merge actions. The primary goal here is to test PR's and get status feedback before merging.

pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12.2"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets go ahead and add 13 to the matrix!

Suggested change
python-version: ["3.12.2"]
python-version: ["3.12.2", "3.13.1"]


steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pipenv
python -m pip install ruff
- name: Lint with ruff
run: |
ruff check
- name: Test with unittest
run: |
cd packages/pythonlab_setup
pipenv install
cd pythonlab_setup
pipenv run python -m unittest
cd ../..
# Repeat install and run unit tests for any other packages with tests.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ This tests adds some customization to the output of unit tests, and has a functi
From the package folder containing `pyproject.toml`, run `python -m build`. The generated `.whl` file will be in the `dist` folder.

## Run tests
From the folder containing code and tests, run `python -m unittest`. This will look for tests in all files that start with `test`.
From the folder containing code and tests, run `pipenv run python -m unittest`. This will look for tests in all files that start with `test`.

# Lint your code
We use [ruff](https://docs.astral.sh/ruff/installation/) for linting. It is a dev dependency of all of our packages. You can install it on
your editor of choice for inline suggestions (for example, [VS Code](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff)),
and run it on the command line via `ruff check`. It also runs as part of the PR check process.
1 change: 1 addition & 0 deletions packages/pythonlab_setup/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ requests = "*"
matplotlib = "*"

[dev-packages]
ruff = "*"

[requires]
python_version = "3.12"
1,021 changes: 564 additions & 457 deletions packages/pythonlab_setup/Pipfile.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/pythonlab_setup/pythonlab_setup/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .setup_pythonlab import setup_pythonlab
from .teardown_pythonlab import teardown_pythonlab
from .setup_pythonlab import setup_pythonlab as setup_pythonlab
from .teardown_pythonlab import teardown_pythonlab as teardown_pythonlab
12 changes: 12 additions & 0 deletions packages/unittest_runner/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]
ruff = "*"

[requires]
python_version = "3.12"
46 changes: 46 additions & 0 deletions packages/unittest_runner/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/unittest_runner/unittest_runner/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .run_tests import run_student_tests, run_validation_tests
from .run_tests import run_student_tests as run_student_tests, run_validation_tests as run_validation_tests
Loading