-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: lint and test using Tox (#4005)
Configures Tox >=4.0 and adds it as a dev requirement, adds a GitHub workflow for tox, and updates the Makefile to use tox environments. The tox configuration includes labels for CI, linting, auto-fixing (fix) and tests.
- Loading branch information
Showing
12 changed files
with
310 additions
and
48 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
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,89 @@ | ||
name: Tox | ||
on: | ||
push: | ||
branches: | ||
- "main" | ||
- "snapcraft/7.0" | ||
- "release/*" | ||
- "hotfix/*" | ||
pull_request: | ||
|
||
jobs: | ||
linters: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
- name: Install dependencies | ||
run: | | ||
echo "::group::Begin snap install" | ||
echo "Installing snaps in the background while running apt and pip..." | ||
sudo snap install --no-wait --classic pyright | ||
sudo snap install --no-wait shellcheck | ||
echo "::endgroup::" | ||
echo "::group::apt-get update" | ||
sudo apt-get update | ||
echo "::endgroup::" | ||
echo "::group::apt-get install..." | ||
sudo apt-get install --yes libapt-pkg-dev libyaml-dev xdelta3 | ||
echo "::endgroup::" | ||
echo "::group::pip install" | ||
python -m pip install 'tox>=4.0.11<5.0' tox-gh | ||
echo "::endgroup::" | ||
echo "::group::Create virtual environments for linting processes." | ||
tox run-parallel --parallel all --parallel-no-spinner -m lint --notest | ||
echo "::endgroup::" | ||
echo "::group::Wait for snap to complete" | ||
snap watch --last=install | ||
echo "::endgroup::" | ||
- name: Run Linters | ||
run: tox run --skip-pkg-install -m lint | ||
tests: | ||
strategy: | ||
fail-fast: false # Run all the tests to their conclusions. | ||
matrix: | ||
platform: [ubuntu-20.04, ubuntu-22.04] | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Python versions on ${{ matrix.platform }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: | | ||
3.8 | ||
3.10 | ||
- name: Install dependencies | ||
run: | | ||
echo "::group::apt-get update" | ||
sudo apt-get update | ||
echo "::endgroup::" | ||
echo "::group::apt-get install..." | ||
sudo apt-get install -y libapt-pkg-dev libyaml-dev xdelta3 | ||
echo "::endgroup::" | ||
echo "::group::pip install" | ||
python -m pip install 'tox>=4.0.11<5.0' tox-gh | ||
echo "::endgroup::" | ||
mkdir -p results | ||
- name: Setup Tox environments | ||
run: tox run-parallel --parallel auto --parallel-no-spinner --parallel-live -m ci --notest | ||
- name: Test with tox | ||
run: tox run-parallel --parallel all --parallel-no-spinner --result-json results/tox-${{ matrix.platform }}.json -m ci --skip-pkg-install -- --no-header --quiet -rN | ||
- name: Upload code coverage | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
directory: ./results/ | ||
files: coverage*.xml | ||
- name: Upload test results | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test-results-${{ matrix.platform }} | ||
path: results/ |
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
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
Oops, something went wrong.