Skip to content
Open
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
168 changes: 135 additions & 33 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,30 @@ executors:
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
build_and_test:
build_distribution:
parameters:
version:
description: "version tag"
default: "latest"
type: string
executor:
name: python-docker
version: <<parameters.version>>
steps:
- checkout
- run:
name: install build dependencies
command: pip install ".[deploy]"
- run:
name: Build distribution artifacts
command: |
python -m build
- persist_to_workspace:
root: .
paths:
- dist

test_source:
parameters:
version:
description: "version tag"
Expand All @@ -36,16 +59,46 @@ jobs:
version: <<parameters.version>>
steps:
- checkout
# - run:
# name: Install System Dependencies
# command: sudo apt-get update && sudo apt-get install -y libsndfile1
- run:
name: install dependencies
command: pip install ".[tests]"
- run:
name: Run tests
command: pytest

test_wheel:
parameters:
version:
description: "version tag"
default: "latest"
type: string
executor:
name: python-docker
version: <<parameters.version>>
steps:
- checkout
- attach_workspace:
at: /tmp/workspace
- run:
name: Install wheel from workspace in isolated venv
command: |
rm -rf /tmp/wheeltest
python -m venv /tmp/wheeltest
# Find the wheel file in the workspace and save it to an environment variable
WHEEL=$(ls -1 /tmp/workspace/dist/*.whl | head -n 1)
/tmp/wheeltest/bin/python -m pip install "${WHEEL}[tests]"
- run:
name: Move test files to isolated location
command: |
rm -rf /tmp/spharpy-wheel-tests
mkdir -p /tmp/spharpy-wheel-tests
cp -r tests /tmp/spharpy-wheel-tests/
- run:
name: Run tests against wheel installation (i.e. in isolated environment)
command: |
cd /tmp/spharpy-wheel-tests
/tmp/wheeltest/bin/python -m pytest tests

ruff:
parameters:
version:
Expand Down Expand Up @@ -75,9 +128,6 @@ jobs:
version: <<parameters.version>>
steps:
- checkout
# - run:
# name: Install System Dependencies
# command: sudo apt-get update && sudo apt-get install -y libsndfile1 texlive-latex-extra dvipng
- run:
name: Sphinx
command: |
Expand All @@ -96,9 +146,6 @@ jobs:
version: <<parameters.version>>
steps:
- checkout
# - run:
# name: Install System Dependencies
# command: sudo apt-get update && sudo apt-get install -y libsndfile1 texlive-latex-extra dvipng
- run:
name: install dependencies
command: pip install ".[tests]"
Expand All @@ -119,17 +166,15 @@ jobs:
version: <<parameters.version>>
steps:
- checkout
# - run:
# name: Install System Dependencies
# command: sudo apt-get update && sudo apt-get install -y libsndfile1
- attach_workspace:
at: /tmp/workspace
- run:
name: install dependencies
command: pip install ".[deploy]"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
command: pip install ".[deploy]"
command: pip install twine

woudnt this be sufficiant?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In theory yes, but I'd like to avoid managing dependencies in the CircleCI config and the pyproject.toml. This way it's always sufficient to extend and update in a single place.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see your point. My thinking here is that this job is only invoking twine, which doesn’t depend on our project’s dependencies or anything that could vary with the package—it’s just a standalone tool.
We could compare it to ruff, but in that case we pin a specific version and install it via the project configuration. Imo this makes sence here, but we dont have this requriedment for twine.
If we want to change the dependency of twine we also need to change this workflow here.
Right now, installing all packages takes about 29 seconds in CI. Installing only twine should be significantly faster. This also scales better, since this job will run for every package on each pull request.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sorry, I still don't really get the point. You could also pin to a specific version within the CircleCI config. My point is more about central management of dependencies in the toml, instead of individual management of dependencies in different places.

I realized though, that its probably more useful to check the binary distribution within the built job instead of creating a new job. This probably saves more time than the 29 secs you mentioned.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

To be honest, I think this job can be removed altogether.
It only checks if the meta-data provided in the pyproject.toml is according to what PyPI expects. More specifically, it only checks the content of the item long_description.
I think it's sufficient to check this before truly releasing a new version and remove the check in PRs, etc.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

that would also work for me

- run:
name: deploy
command: | # create whl, install twine and publish to Test PyPI
python -m build
twine check dist/*
command: |
twine check /tmp/workspace/dist/*

run_pypi_publish:
parameters:
Expand All @@ -142,26 +187,24 @@ jobs:
version: <<parameters.version>>
steps:
- checkout
- run:
name: Install System Dependencies
command: sudo apt-get update && sudo apt-get install -y libsndfile1
- attach_workspace:
at: /tmp/workspace
- run:
name: install dependencies
command: pip install ".[deploy]"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
command: pip install ".[deploy]"
command: pip install twine

same here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

see comment above

- run:
name: deploy
command: | # create whl, install twine and publish to Test PyPI
python -m build
twine check dist/*
twine upload dist/*
command: |
twine check /tmp/workspace/dist/*
twine upload /tmp/workspace/dist/*

# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
test: # Test workflow
jobs:
# Run tests for all python versions
- build_and_test:
- test_source:
matrix:
parameters:
version:
Expand All @@ -170,44 +213,69 @@ workflows:
- "3.13"
- "3.14"

- build_distribution:
matrix:
parameters:
version:
- "3.14"
requires:
- test_source

- ruff:
matrix:
parameters:
version:
- "3.14"
requires:
- build_and_test
- test_source

- test_wheel:
matrix:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

to reduce redandency we could also jsut run test_wheel on main and develop and not for each pull in a pr

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll update that at the end, to make sure it still triggers as long as work on this PR is ongoing

parameters:
version:
- "3.11"
- "3.12"
- "3.13"
- "3.14"
requires:
- build_distribution

- test_documentation_build:
matrix:
parameters:
version:
- "3.14"
requires:
- build_and_test
- test_source

- test_deprecation_warnings:
matrix:
parameters:
version:
- "3.14"
requires:
- build_and_test
- test_source

- test_pypi_publish:
matrix:
parameters:
version:
- "3.14"
requires:
- build_and_test
- test_source
- build_distribution
filters:
branches:
only:
- main
- develop


test_and_publish:
# Test and publish on new git version tags
# This requires its own workflow to successfully trigger the test and build
jobs:
- build_and_test:
- test_source:
matrix:
parameters:
version:
Expand All @@ -223,13 +291,45 @@ workflows:
tags:
only: /^v[0-9]+(\.[0-9]+)*$/

- build_distribution:
matrix:
parameters:
version:
- "3.14"
requires:
- test_source
filters:
branches:
ignore: /.*/
# only act on version tags
tags:
only: /^v[0-9]+(\.[0-9]+)*$/

- ruff:
matrix:
parameters:
version:
- "3.14"
requires:
- build_and_test
- test_source
filters:
branches:
ignore: /.*/
# only act on version tags
tags:
only: /^v[0-9]+(\.[0-9]+)*$/

- test_wheel:
matrix:
parameters:
version:
- "3.11"
- "3.12"
- "3.13"
- "3.14"
requires:
- test_source
- build_distribution
filters:
branches:
ignore: /.*/
Expand All @@ -243,7 +343,7 @@ workflows:
version:
- "3.14"
requires:
- build_and_test
- test_source
filters:
branches:
ignore: /.*/
Expand All @@ -257,7 +357,7 @@ workflows:
version:
- "3.14"
requires:
- build_and_test
- test_source
filters:
branches:
ignore: /.*/
Expand All @@ -271,7 +371,9 @@ workflows:
version:
- "3.14"
requires:
- build_and_test
- test_source
- test_wheel
- build_distribution
- ruff
- test_documentation_build
filters:
Expand Down