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

Provide CI testing support #8

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
15 changes: 15 additions & 0 deletions .github/actions/prepare-tox/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# A composite action to prepare tox-based workflows

name: "Prepare tox"

description: "Prepare tox-based workflows"

runs:
using: "composite"
steps:
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems reasonable to also require installing Python here. Are there compelling reasons why choosing a standard version (3.11) and using that for all tox jobs wouldn't work?

Copy link
Member Author

@mitchnegus mitchnegus Nov 18, 2024

Choose a reason for hiding this comment

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

The reason I had not included that one was because I hadn't put thought into how the matrixing versions (in lint) and full inclusion of all versions (in the tests) should be reconciled.

When we run tox -e py39,py310,... it runs an individual tox job for tests for each. That means that the runner has to have all those versions of Python installed to start with, because tox will look for each Python as it runs each job. But for linting, our tox -e lint job will just use whichever Python is the default in our virtual environment (I think).

The setup-python action seems to allow you to specify the default Python version as the last version identified among multiple selected. I'd think if nothing else we might want to control which version is used for linting (e.g., 3.11 like you suggested).

Also, another concern that popped into my head might be that there could be a performance penalty for installing all versions of Python for the linting job. From what I can see on the pipelines right now, it's less than 1 second for just one version at a time and closer to 9 seconds to install all 6 (Python 3.8 through 3.13). That's not huge for a CI pipeline—especially if it's running concurrent with tests which will almost always take far longer—so I'm inclined to think it's not a big deal.

- name: "Ensure upgraded pip"
run: pip install --upgrade pip
shell: bash
- name: "Install tox"
run: pip install tox
shell: bash
9 changes: 3 additions & 6 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# This workflow will build and deploy the FIREWHEEL documentation

name: Documentation

Expand Down Expand Up @@ -38,9 +37,7 @@ jobs:
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
uses: ./.github/actions/prepare-tox
- name: Build Documentation
run: |
tox -e dependencies,docs
Expand All @@ -60,4 +57,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v4
6 changes: 2 additions & 4 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# This workflow will install Python dependencies and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Linting
Expand Down Expand Up @@ -27,9 +27,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
uses: ./.github/actions/prepare-tox
- name: Lint code
run: |
tox -e lint
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will install Python dependencies and run tests with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Testing

on:
push:
branches: [ "*" ]
pull_request:
branches: [ "main" ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: |
3.8
3.9
3.10
3.11
3.12
3.13
- name: Install dependencies
uses: ./.github/actions/prepare-tox
- name: Run unit tests
run: |
tox -e py38,py39,py310,py311,py312,py313
5 changes: 3 additions & 2 deletions src/firewheel/tests/unit/cli/test_cli_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
from unittest.mock import Mock, patch, mock_open

from firewheel.config import config
from firewheel.cli.completion import COMPLETION_SCRIPT_PATH
from firewheel.cli.completion.actions import (
_keyboard_interruptable,
Expand Down Expand Up @@ -95,8 +96,8 @@ def test_populate_template(self):
mock_handle.write.assert_called_once()
script_content = mock_handle.write.call_args.args[0]
filled_placeholders = [
'fw_venv="/opt/firewheel/fwpy"',
'python_bin="python3"',
f"fw_venv=\"{config['python']['venv']}\"",
f"python_bin=\"{config['python']['bin']}\"",
]
assert all(_ in script_content for _ in filled_placeholders)

Expand Down
Loading