-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #431 from UW-GAC/maint/use-hatch
Migrate to hatch
- Loading branch information
Showing
14 changed files
with
355 additions
and
281 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
name: ci-tox | ||
|
||
# Enable Buildkit and let compose use it to speed up image building | ||
env: | ||
DOCKER_BUILDKIT: 1 | ||
COMPOSE_DOCKER_CLI_BUILD: 1 | ||
name: hatch-tests | ||
|
||
on: | ||
pull_request: | ||
|
@@ -16,143 +11,83 @@ on: | |
|
||
|
||
jobs: | ||
|
||
linter: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout Code Repository | ||
uses: actions/[email protected] | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Run pre-commit | ||
uses: pre-commit/[email protected] | ||
|
||
|
||
sqlite: | ||
runs-on: ubuntu-latest | ||
test: | ||
strategy: | ||
fail-fast: false | ||
max-parallel: 10 | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade tox tox-gh-actions | ||
- name: Test with tox | ||
# Sometimes tox fails to build the package correctly and intermittently throws an OSError or BadZipFile error. | ||
# Upon retry, it seems to work. | ||
uses: nick-fields/retry@v2 | ||
id: retry-sqlite | ||
with: | ||
timeout_minutes: 10 | ||
max_attempts: 3 | ||
retry_on: error | ||
command: tox | ||
env: | ||
DBBACKEND: sqlite3 | ||
DBNAME: ":memory:" | ||
|
||
- name: Upload coverage data | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage-data | ||
path: ".coverage.*" | ||
|
||
|
||
mysql: | ||
python-version: ["3.8", "3.11"] | ||
django-version: ["3.2", "4.2"] | ||
backend: ["sqlite", "mysql"] | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
max-parallel: 10 | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
mariadb-version: ["10.4"] | ||
env: | ||
PYTEST_ADDOPTS: "--maxfail=20" # Stop testing after too many failures. | ||
TEST_ENV: "test-${{ matrix.backend }}.py${{ matrix.python-version }}-${{ matrix.django-version }}" | ||
|
||
services: | ||
database: | ||
image: mariadb:${{ matrix.mariadb-version }} | ||
image: mariadb:10.4 | ||
env: | ||
MYSQL_ROOT_PASSWORD: rootpw | ||
MYSQL_DATABASE: test | ||
|
||
ports: | ||
- 3306:3306 | ||
options: --tmpfs /var/lib/mysql | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade tox tox-gh-actions | ||
- name: Test with tox | ||
# Sometimes tox fails to build the package correctly and intermittently throws an OSError or BadZipFile error. | ||
# Upon retry, it seems to work. | ||
uses: nick-fields/retry@v2 | ||
id: retry-mysql | ||
with: | ||
timeout_minutes: 10 | ||
max_attempts: 3 | ||
retry_on: error | ||
command: tox | ||
env: | ||
DBBACKEND: mysql | ||
DBNAME: test | ||
DBUSER: root | ||
DBPASSWORD: rootpw | ||
DBHOST: 127.0.0.1 | ||
|
||
- name: Upload coverage data | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage-data | ||
path: ".coverage.*" | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install hatch | ||
run: python -m pip install --upgrade hatch | ||
|
||
- name: Set environment variables | ||
if: ${{ matrix.backend == 'mysql' }} | ||
run: | | ||
echo "DBNAME=test" >> $GITHUB_ENV | ||
echo "DBUSER=root" >> $GITHUB_ENV | ||
echo "DBPASSWORD=rootpw" >> $GITHUB_ENV | ||
echo "DBHOST=127.0.0.1" >> $GITHUB_ENV | ||
- name: Run Tests | ||
run: hatch run $TEST_ENV:cov | ||
|
||
- name: Upload coverage data | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage-data | ||
path: ".coverage.*" | ||
|
||
|
||
coverage: | ||
|
||
|
||
name: Check coverage. | ||
runs-on: "ubuntu-latest" | ||
needs: [sqlite, mysql] | ||
needs: [test] | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
- uses: actions/setup-python@v4 | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
# Use latest, so it understands all syntax. | ||
python-version: "3.10" | ||
python-version: "3.11" | ||
|
||
- run: python -m pip install --upgrade coverage[toml] django==3.2.16 django-coverage-plugin | ||
- name: Install hatch | ||
run: python -m pip install --upgrade hatch | ||
|
||
- name: Download coverage data. | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: coverage-data | ||
|
||
- name: Combine coverage & check percentage | ||
run: | | ||
python -m coverage combine | ||
python -m coverage xml | ||
run: hatch run cov-combine:combine | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
|
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,99 @@ | ||
name: hatch-tests | ||
|
||
on: | ||
pull_request: | ||
branches: [ "master", "main" ] | ||
paths-ignore: [ "docs/**" ] | ||
|
||
push: | ||
branches: [ "master", "main" ] | ||
paths-ignore: [ "docs/**" ] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
|
||
test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.8", "3.11"] | ||
django-version: ["3.2", "4.2"] | ||
backend: ["sqlite", "mysql"] | ||
runs-on: ubuntu-latest | ||
env: | ||
PYTEST_ADDOPTS: "--maxfail=20" # Stop testing after too many failures. | ||
TEST_ENV: "test-${{ matrix.backend }}.py${{ matrix.python-version }}-${{ matrix.django-version }}" | ||
|
||
services: | ||
database: | ||
image: mariadb:10.4 | ||
env: | ||
MYSQL_ROOT_PASSWORD: rootpw | ||
MYSQL_DATABASE: test | ||
|
||
ports: | ||
- 3306:3306 | ||
options: --tmpfs /var/lib/mysql | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install hatch | ||
run: python -m pip install --upgrade hatch | ||
|
||
- name: Set environment variables | ||
if: ${{ matrix.backend == 'mysql' }} | ||
run: | | ||
echo "DBNAME=test" >> $GITHUB_ENV | ||
echo "DBUSER=root" >> $GITHUB_ENV | ||
echo "DBPASSWORD=rootpw" >> $GITHUB_ENV | ||
echo "DBHOST=127.0.0.1" >> $GITHUB_ENV | ||
- name: Run Tests | ||
run: hatch run $TEST_ENV:cov | ||
|
||
- name: Upload coverage data | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage-data | ||
path: ".coverage.*" | ||
|
||
|
||
coverage: | ||
|
||
|
||
name: Check coverage. | ||
runs-on: "ubuntu-latest" | ||
needs: [test] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
|
||
- name: Install hatch | ||
run: python -m pip install --upgrade hatch | ||
|
||
- name: Download coverage data. | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: coverage-data | ||
|
||
- name: Combine coverage & check percentage | ||
run: hatch run cov-combine:combine | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |
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 |
---|---|---|
|
@@ -277,3 +277,4 @@ example_site/media/ | |
### My additions | ||
db.sqlite3 | ||
*.sqlite3 | ||
.env |
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.