Skip to content

Commit

Permalink
add github actions and other CI files
Browse files Browse the repository at this point in the history
  • Loading branch information
adehad committed Jan 14, 2024
1 parent feb7aaa commit cc24244
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 10 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# Set update schedule for GitHub Actions
version: 2
updates:
- package-ecosystem: "github-actions"
target-branch: main
directory: "/"
open-pull-requests-limit: 10
schedule:
interval: "monthly"
labels:
- "dependencies"
- "skip-changelog"
17 changes: 17 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Update dependencies
# Dependabot does not recognise PDM so we use the PDM version

on:
# schedule:
# - cron: "0 0 1 * *" # monthly
workflow_dispatch:

jobs:
update-dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Update dependencies
uses: pdm-project/update-deps-action@main
71 changes: 71 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: test

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

concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
QT_SELECT: "qt6"
QT_QPA_PLATFORM: "offscreen"

jobs:
run:
name: >
Python ${{ matrix.python-version }} on
${{
startsWith(matrix.os, 'macos-') && 'macOS'
|| startsWith(matrix.os, 'windows-') && 'Windows'
|| 'Linux'
}}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
# os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.12"]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Set up ${{ matrix.os }}
run: |
sudo apt-get update; sudo apt-get install qt6-base-dev qt6-tools-dev qt6-tools-dev-tools qt6-wayland qt6-l10n-tools
qtchooser -install qt6 $(which qmake6)
- name: Setup PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}
cache: true

- name: Install dependencies
run: pdm install

- name: Run lints # These benefit from the autogenerated files
run: pdm run mypy

- name: Run tests
run: pdm run cov

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./dist/cov/coverage.xml
name: ${{ runner.os }}-${{ matrix.python-version }}
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ repos:
hooks:
- id: yamllint
files: \.(yaml|yml)$
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies:
- .[dev]
args: [--show-error-codes]
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
Expand Down
24 changes: 24 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
version: 2
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

build:
os: ubuntu-22.04
tools:
python: "3.12"
# apt_packages: # Keep in sync with Dockerfile
# - qt6-base-dev
# - qt6-tools-dev
# - qt6-tools-dev-tools
# - qt6-wayland
# - qt6-l10n-toolslibclang
jobs:
post_create_environment:
- pip install pdm
post_install:
- pdm use -f $READTHEDOCS_VIRTUALENV_PATH
- pdm install

sphinx:
configuration: docs/conf.py
fail_on_warning: false # false until we want to have it install all deps and build
13 changes: 13 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
"""Sphinx configuration."""
from __future__ import annotations

import os
import sys
from pathlib import Path
from unittest.mock import MagicMock

import app as app

# -- Import configuration ------------------------------------------------------
if os.environ.get("READTHEDOCS"):
# The compiled UI libraries don't need to be generated for the documentation.
# Therefore we just stub them out when running on the readthedocs runners.
# Is this necessary? No, but probably a more responsible use of build time.
for potential_ui_file in (Path(__file__).parent / "../src/app").rglob("*.ui"):
sys.modules[f"app._ui.{potential_ui_file.stem}_ui"] = MagicMock()

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand Down
2 changes: 1 addition & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ app = "app.__main__:main"

[project.optional-dependencies]
dev = [
# Lint
"mypy>=1.8.0",
# Installer
"PyInstaller>=6.3.0",
# Docs
Expand Down Expand Up @@ -51,6 +53,9 @@ cov = "pytest -vv --cov-report=term-missing --cov-config=pyproject.toml --cov=sr
docs = "sphinx-build -a -n -v -W --keep-going -b html --color -d dist/docs_doctree docs/ {args:dist/docs}"
exe = "pyinstaller app.spec"

# Can't run in pre-commit as needs autogenerated files and deps
mypy = "mypy src"

########################################################################################
# External Tool Config
########################################################################################
Expand Down
4 changes: 2 additions & 2 deletions src/app/_ui/_autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def run():
src=str(ui_file),
target=f"{dest_path / ui_file.stem}_ui.py",
)
pass


if __name__ == "__main__":
run()
if not any([os.environ.get(e) for e in {"READTHEDOCS"}]):
run()

0 comments on commit cc24244

Please sign in to comment.