-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pytests, and remove explicit workflow testing (#430)
* Add pytests, and remove explicit workflow testing * Don't test something we can't test in CI. * Add dependency. * Update tests/test_package_creation.py Remove extra spaces. --------- Co-authored-by: Drew Oldag <[email protected]>
- Loading branch information
1 parent
b22e735
commit d395883
Showing
4 changed files
with
131 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,121 +5,26 @@ on: | |
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
schedule: | ||
- cron: 45 6 * * * | ||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
tests: | ||
name: ${{ matrix.copier_config.name }} - Python ${{ matrix.python-version }} | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
python-version: ['3.9', '3.10', '3.11'] | ||
copier_config: | ||
- name: Base example | ||
package_name: example_package # The default package_name | ||
extra_flags: '' | ||
foldername: base_example | ||
- name: No example module | ||
package_name: 'drewtonian' # Same module name provided in `extra_flags` on the next line. | ||
extra_flags: >- | ||
--data project_name=new_science | ||
--data package_name=drewtonian | ||
--data author_name=Drew | ||
--data [email protected] | ||
--data project_license=BSD | ||
--data mypy_type_checking=basic | ||
--data create_example_module=no | ||
--data include_notebooks=no | ||
foldername: 'black_w_o_example_module' | ||
- name: Example module | ||
package_name: 'drewtonian' # Same module name provided in `extra_flags` on the next line. | ||
extra_flags: >- | ||
--data project_name=new_science | ||
--data package_name=drewtonian | ||
--data author_name=Drew | ||
--data [email protected] | ||
--data project_license=BSD | ||
--data mypy_type_checking=basic | ||
--data create_example_module=yes | ||
--data include_notebooks=no | ||
foldername: 'black_w_example_module' | ||
- name: No sphinx docs | ||
package_name: 'drewtonian' | ||
extra_flags: >- | ||
--data project_name=new_science | ||
--data package_name=drewtonian | ||
--data include_docs=no | ||
--data include_notebooks=no | ||
foldername: 'no_sphinx_docs' | ||
python-version: ['3.9', '3.10', '3.11', '3.12'] | ||
|
||
steps: | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
- uses: actions/checkout@main | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@main | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install Python dependencies | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
python -m pip install --upgrade pip | ||
python -m pip install copier mypy | ||
- name: Generate package | ||
run: | | ||
copier copy --vcs-ref HEAD --defaults ${{ matrix.copier_config.extra_flags }} ./ ../test/${{ matrix.copier_config.foldername }} | ||
cd ../test/${{ matrix.copier_config.foldername }} | ||
cat .copier-answers.yml | ||
- name: Build package | ||
run: | | ||
cd ../test/${{ matrix.copier_config.foldername }} | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Test Name" | ||
git init --initial-branch=main | ||
git add src | ||
git commit -m initial | ||
pip install .[dev] | ||
- name: black checks | ||
uses: psf/black@stable | ||
with: | ||
src: "../test/${{ matrix.copier_config.foldername }}/src" | ||
|
||
- name: mypy checks basic | ||
if: ${{ contains(matrix.copier_config.extra_flags, 'mypy_type_checking=basic') && !contains(matrix.copier_config.extra_flags, 'create_example_module=no') }} | ||
run: | | ||
cd "../test/${{ matrix.copier_config.foldername }}" | ||
mypy src tests | ||
- name: mypy checks strict | ||
if: ${{ contains(matrix.copier_config.extra_flags, 'mypy_type_checking=strict') && !contains(matrix.copier_config.extra_flags, 'create_example_module=no') }} | ||
run: | | ||
cd "../test/${{ matrix.copier_config.foldername }}" | ||
mypy --strict src tests | ||
- name: Install notebook requirements | ||
if: ${{ !contains(matrix.copier_config.extra_flags, 'include_notebooks=no') }} | ||
run: | | ||
sudo apt-get install pandoc | ||
pip install -r ../test/${{ matrix.copier_config.foldername }}/docs/requirements.txt | ||
cat ../test/${{ matrix.copier_config.foldername }}/docs/requirements.txt | ||
- name: Build docs | ||
if: ${{ !contains(matrix.copier_config.extra_flags, 'include_docs=no') }} | ||
run: | | ||
cd ../test/${{ matrix.copier_config.foldername }} | ||
sphinx-build -T -E -b html -d docs/build/doctrees ./docs docs/build/html | ||
- name: Tests | ||
if: ${{ !contains(matrix.copier_config.extra_flags, 'create_example_module=no') }} | ||
pip install -e .[dev] | ||
- name: Run unit tests with pytest / pytest-copie | ||
run: | | ||
cd ../test/${{ matrix.copier_config.foldername }} | ||
python -m pytest --cov=${{ matrix.copier_config.package_name }} --cov-report=xml | ||
python -m pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# This workflow will run daily at 06:45. | ||
# It will install Python dependencies and run tests with a variety of Python versions. | ||
# See documentation for help debugging smoke test issues: | ||
# https://lincc-ppt.readthedocs.io/en/latest/practices/ci_testing.html#version-culprit | ||
|
||
name: Unit test smoke test | ||
|
||
on: | ||
|
||
# Runs this workflow automatically | ||
schedule: | ||
- cron: 45 6 * * * | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ['3.9', '3.10', '3.11', '3.12'] | ||
|
||
steps: | ||
- uses: actions/checkout@main | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@main | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
python -m pip install --upgrade pip | ||
pip install -e .[dev] | ||
- name: List dependencies | ||
run: | | ||
pip list | ||
- name: Run unit tests with pytest / pytest-copie | ||
run: | | ||
python -m pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters