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

Integrate with Starbase #422

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6fe4c5b
chore(linter): use starbase
syu-w Nov 28, 2023
42670ba
chore(deps): sync dev deps with starbase
syu-w Nov 28, 2023
ab04163
chore(tests): update tox.ini with starbase
syu-w Nov 28, 2023
c20d6d5
chore(linter): update to 3.10 style
syu-w Nov 28, 2023
518aa7e
chore(linter): misc auto fix
syu-w Nov 28, 2023
bbb3493
chore(linter): use tuple for pytest.mark.parametrize
syu-w Nov 28, 2023
9fc89bc
chore(linter): create list without concatenate
syu-w Nov 28, 2023
d9ef893
chore(linter): misc fix
syu-w Nov 28, 2023
d1a6efb
chore(linter): fix some annotations
syu-w Nov 28, 2023
d4b888a
chore(linter): temporarily turn off unfixed rules
syu-w Nov 29, 2023
39303dc
feat(project): migrate to pyproject.toml
syu-w Nov 29, 2023
7dd8598
feat(ci): use tox.ini for ci
syu-w Nov 29, 2023
f7ce055
test: allow venv sh shebang
syu-w Nov 30, 2023
cecd533
docs: use starbase readthedocs
syu-w Nov 30, 2023
aaca617
test(docs): delete docs build spread test
syu-w Dec 1, 2023
d48cb9a
chore(linter): fix mypy annotation errors
syu-w Dec 1, 2023
3144a2b
chore(linter): fix pyright annotation errors
syu-w Dec 1, 2023
7d2cd8e
chore(linter): fix docs linter errors
syu-w Dec 1, 2023
a3c4eac
chore(linter): fix yaml linter errors
syu-w Dec 1, 2023
b17987a
Merge branch 'main' into CRAFT-2249-starbase
syu-w Dec 4, 2023
49990bc
chore(ci): sync pre commit config with pyproject
syu-w Dec 4, 2023
33e8ca3
chore(linter): move run_user typing to the top
syu-w Dec 4, 2023
af5594d
chore(linter): fix _create_app return type
syu-w Dec 4, 2023
5ad6554
chore: update the snapcraft workaround comment
syu-w Dec 4, 2023
83ffa4f
chore(linter): increase line length for README
syu-w Dec 4, 2023
aaf57c0
fix: use values for get services
syu-w Dec 4, 2023
bf6a312
test: disable tests that will not work in tox
syu-w Dec 4, 2023
c8c2259
test(spread): add an spread test for shebang
syu-w Dec 5, 2023
d12616a
docs: update the how-to build docs to use tox
syu-w Dec 5, 2023
20a0ab9
chore(ci): fix naming
syu-w Dec 5, 2023
a1fd0ef
chore(deps): use requirements.txt with pyproject.toml
syu-w Dec 5, 2023
a3417f8
chore(snap): use setup.py
syu-w Dec 5, 2023
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
43 changes: 43 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Editor configuration options.
# See: https://spec.editorconfig.org/
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[.editorconfig]
max_line_length = off

[Makefile]
indent_style = tab

[{*.py,*.pyi}]
max_line_length = 88

[{*.bash,*.sh,*.zsh}]
indent_size = 2
tab_width = 2

[{*.har,*.json,*.json5}]
indent_size = 2
max_line_length = off

[{*.markdown,*.md,*.rst}]
max_line_length = off
ij_visual_guides = none

[{*.toml,Cargo.lock,Cargo.toml.orig,Gopkg.lock,Pipfile,poetry.lock}]
max_line_length = off

[{*.ini, *.cfg}]
max_line_length = off

[{*.yaml,*.yml}]
indent_size = 2
max_line_length = off
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@ body:
render: shell
validations:
required: true

2 changes: 1 addition & 1 deletion .github/workflows/snap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]
then
echo "branch=pr-${{ github.event.number }}" >> "$GITHUB_OUTPUT"
echo "branch=pr-${{ github.event.number }}" >> "$GITHUB_OUTPUT"
else
branch=$(echo ${GITHUB_REF#refs/*/} | sed -e 's|feature/\(.*\)|\1|')
echo "branch=$branch" >> "$GITHUB_OUTPUT"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/spread-large.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Spread (large)
on:
pull_request:
types: [ labeled ]
types: [labeled]
schedule:
- cron: "0 2 * * 0,3" # run at 2 AM on Sundays and Wednesdays
- cron: "0 2 * * 0,3" # run at 2 AM on Sundays and Wednesdays

jobs:
snap-build:
Expand Down
181 changes: 108 additions & 73 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,108 +1,143 @@
name: Tests

on:
pull_request:
push:
branches:
- main
- "main"
- "feature/*"
- "hotfix/*"
- "release/*"
- "renovate/*"
pull_request:

jobs:
linters:
lint:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: conventional commits
syu-w marked this conversation as resolved.
Show resolved Hide resolved
uses: webiny/[email protected]
- name: Install packages
run: |
sudo apt update
sudo apt install -y libapt-pkg-dev aspell aspell-en
- name: Set up Python 3.10
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install python packages and dependencies
run: |
pip install -U wheel -r requirements-jammy.txt -r requirements.txt -r requirements-dev.txt
pip install -e .
- name: Run black
run: |
make test-black
- name: Run codespell
run: |
make test-codespell
- name: Run flake8
run: |
make test-flake8
- name: Run isort
run: |
make test-isort
- name: Run mypy
run: |
make test-mypy
- name: Run pydocstyle
run: |
make test-pydocstyle
- name: Run pyright
run: |
sudo snap install --classic node
sudo snap install --classic pyright
make test-pyright
- name: Run pylint
run: |
make test-pylint
- name: Run sphinx-lint
run: |
make test-sphinx-lint
- name: Run shellcheck
run: |
sudo snap install shellcheck
make test-shellcheck
- name: Run linkcheck,woke,spelling
run: |
sudo snap install woke
make test-docs

tests:
python-version: '3.10'
cache: 'pip'
- name: Configure environment
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::pip install"
python -m pip install tox
echo "::endgroup::"
echo "::group::Create virtual environments for linting processes."
tox run --colored yes -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 --no-list-dependencies --colored yes -m lint
unit:
strategy:
matrix:
os: [ubuntu-22.04, windows-2019]
python-version: ["3.10", "3.12"]

runs-on: ${{ matrix.os }}
platform: [ubuntu-22.04, windows-2019]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install python packages and dependencies
run: |
pip install -U wheel
python-version: |
3.10
3.12
cache: 'pip'
- name: Install Ubuntu-specific dependencies
if: ${{ startsWith(matrix.os, 'ubuntu') }}
if: ${{ startsWith(matrix.platform, 'ubuntu') }}
run: |
sudo apt update
sudo apt install -y python3-pip python3-setuptools python3-wheel python3-venv libapt-pkg-dev
sudo apt install -y libapt-pkg-dev
- name: Install Ubuntu 22.04-specific dependencies
if: ${{ matrix.os == 'ubuntu-22.04' }}
if: ${{ matrix.platform == 'ubuntu-22.04' }}
run: |
pip install -U -r requirements-jammy.txt
# 22.04 is the only one that has an 'umoci' package
sudo apt install -y umoci
- name: Install dependencies
run: |
pip install -U -r requirements.txt -r requirements-dev.txt
pip install -e .
- name: Run unit tests
- name: Configure environment
run: |
echo "::group::pip install"
python -m pip install tox
echo "::endgroup::"
mkdir -p results
- name: Setup Tox environments
run: tox run --colored yes -m tests --notest
- name: Test with tox
run: tox run --skip-pkg-install --no-list-dependencies --result-json results/tox-${{ matrix.platform }}.json --colored yes -m unit-tests
env:
PYTEST_ADDOPTS: "--no-header -vv -rN"
- name: Upload code coverage
uses: codecov/codecov-action@v3
with:
directory: ./results/
files: coverage*.xml
- name: Upload test results
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: test-results-${{ matrix.platform }}
path: results/
integration:
strategy:
matrix:
platform: [ubuntu-22.04, windows-2019]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: |
3.10
3.12
cache: 'pip'
- name: Install Ubuntu-specific dependencies
if: ${{ startsWith(matrix.platform, 'ubuntu') }}
run: |
make test-units
- name: Run integration tests
sudo apt update
sudo apt install -y libapt-pkg-dev
- name: Install Ubuntu 22.04-specific dependencies
if: ${{ matrix.platform == 'ubuntu-22.04' }}
run: |
make test-integrations

# 22.04 is the only one that has an 'umoci' package
sudo apt install -y umoci
- name: Configure environment
run: |
echo "::group::pip install"
python -m pip install tox
echo "::endgroup::"
mkdir -p results
- name: Setup Tox environments
run: tox run --colored yes -m tests --notest
- name: Test with tox
run: tox run --skip-pkg-install --no-list-dependencies --result-json results/tox-${{ matrix.platform }}.json --colored yes -m integration-tests
env:
PYTEST_ADDOPTS: "--no-header -vv -rN"
- name: Upload test results
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: test-results-${{ matrix.platform }}
path: results/
36 changes: 18 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ coverage.xml
.hypothesis/
.pytest_cache/

# Spread tests
.spread-reuse.yaml

# Translations
*.mo
*.pot
Expand All @@ -73,6 +70,8 @@ instance/

# Sphinx documentation
docs/_build/
docs/reference/commands
docs/sphinx-starter-pack/

# PyBuilder
target/
Expand Down Expand Up @@ -131,27 +130,28 @@ dmypy.json

# Pyre type checker
.pyre/
# IDE settings
.vscode/

# Caches for various tools
/.*_cache/

# Test results
/results/

# direnv
.direnv
.envrc

# snap
rockcraft_*.snap
# Ignore version module generated by setuptools_scm
/*/_version.py

# rock
*.rock
# Visual Studio Code
.vscode/

# sphinx
# Ignore external tools
/tools/external/

docs/warnings.txt
docs/.sphinx/.wordlist.dic
docs/reference/commands
.DS_Store
__pycache__
.idea/
# snap
rockcraft_*.snap

# build-generated version file
rockcraft/_version.py
# rock
*.rock
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
syu-w marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- id: check-toml
- id: fix-byte-order-marker
- id: mixed-line-ending
- repo: https://github.com/charliermarsh/ruff-pre-commit
# renovate: datasource=pypi;depName=ruff
rev: "v0.1.6"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
# renovate: datasource=pypi;depName=black
rev: "23.11.0"
hooks:
- id: black
- repo: https://github.com/adrienverge/yamllint.git
# renovate: datasource=pypi;depName=yamllint
rev: "v1.33.0"
hooks:
- id: yamllint
Loading