Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into hotfix/7.3-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiusens committed Mar 10, 2023
2 parents bef32e2 + abe37bc commit 61b98a1
Show file tree
Hide file tree
Showing 101 changed files with 921 additions and 4,763 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
# Secrets cannot be used in conditionals, so this is our dance:
# https://github.com/actions/runner/issues/520
if [[ -n "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}" ]]; then
echo "::set-output name=PUBLISH::true"
echo PUBLISH=true >> $GITHUB_OUTPUT
else
echo "::set-output name=PUBLISH::"
echo PUBLISH= >> $GITHUB_OUTPUT
fi
- if: steps.decisions.outputs.PUBLISH == 'true'
name: Checkout Snapcraft
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
# Fetch all of history so Snapcraft can determine its own version from git.
fetch-depth: 0
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/spread.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

steps:
- name: Checkout snapcraft
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand All @@ -17,7 +17,7 @@ jobs:
uses: snapcore/action-build@v1

- name: Upload snapcraft snap
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: snap
path: ${{ steps.build-snapcraft.outputs.snap }}
Expand All @@ -44,7 +44,7 @@ jobs:

steps:
- name: Checkout snapcraft
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
Expand Down Expand Up @@ -87,14 +87,14 @@ jobs:
# Secrets cannot be used in conditionals, so this is our dance:
# https://github.com/actions/runner/issues/520
if [[ -n "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS_STAGING }}" ]]; then
echo "::set-output name=RUN::true"
echo RUN=true >> $GITHUB_OUTPUT
else
echo "::set-output name=RUN::"
echo RUN= >> $GITHUB_OUTPUT
fi
- if: steps.decisions.outputs.RUN == 'true'
name: Checkout snapcraft
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/tox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
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
python -m pip install 'tox<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
tox run -m lint --notest
echo "::endgroup::"
echo "::group::Wait for snap to complete"
snap watch --last=install
Expand All @@ -49,17 +49,21 @@ jobs:
fail-fast: false # Run all the tests to their conclusions.
matrix:
platform: [ubuntu-20.04, ubuntu-22.04]
python_version: ["3.8", "3.10"]
include:
- python_version: "3.8"
tox_python: py38
- python_version: "3.10"
tox_python: py310
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python versions on ${{ matrix.platform }}
- name: Set up Python version ${{ matrix.python_version }} on ${{ matrix.platform }}
uses: actions/setup-python@v4
with:
python-version: |
3.8
3.10
python-version: ${{ matrix.python_version }}
- name: Install dependencies
run: |
echo "::group::apt-get update"
Expand All @@ -69,20 +73,20 @@ jobs:
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
python -m pip install 'tox<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
run: tox run-parallel --parallel auto --parallel-no-spinner --parallel-live -e test-${{ matrix.tox_python }},test-legacy-${{ matrix.tox_python }} --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
run: tox run --skip-pkg-install --result-json results/tox-${{ matrix.platform }}.json -e test-${{ matrix.tox_python }},test-legacy-${{ matrix.tox_python }}
- name: Upload code coverage
uses: codecov/codecov-action@v3
with:
directory: ./results/
files: coverage*.xml
- name: Upload test results
if: always()
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: test-results-${{ matrix.platform }}
Expand Down
29 changes: 29 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Variances from starbase:
# * Thruthiness checks set to warning
# * Indentation checks disabled
# * Trailing spaces checks disabled
# * Comment checks disabled
# * Empty line checks disabled
# * New line at end of file check disabled
# * Bracket spaces checks disabled
---
ignore-from-file: [.gitignore]

extends: default

rules:
document-start: disable
float-values: enable
line-length: disable
octal-values: enable
truthy:
check-keys: false
# Changes from starbase start here
level: warning
indentation: disable
trailing-spaces: disable
comments: disable
comments-indentation: disable
empty-lines: disable
new-line-at-end-of-file: disable
brackets: disable
23 changes: 11 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@ SOURCES_LEGACY=snapcraft_legacy tests/legacy

.PHONY: autoformat-black
autoformat-black:
tox run -e format
tox run -e format-black

.PHONY: freeze-requirements
freeze-requirements:
tools/freeze-requirements.sh

.PHONY: test-black
test-black:
tox run -e black
tox run -e lint-black

.PHONY: test-codespell
test-codespell:
tox run -e codespell
tox run -e lint-codespell

.PHONY: test-isort
test-isort:
tox run -e isort
tox run -e lint-isort

.PHONY: test-mypy
test-mypy:
tox run -e mypy
tox run -e lint-mypy

.PHONY: test-pydocstyle
test-pydocstyle:
tox run -e docstyle
tox run -e lint-docstyle

.PHONY: test-pylint
test-pylint:
tox run -e pylint
tox run -e lint-pylint

.PHONY: test-pyright
test-pyright:
tox run -e pyright
tox run -e lint-pyright

.PHONY: test-ruff
test-ruff:
Expand All @@ -44,16 +44,15 @@ test-ruff:

.PHONY: test-shellcheck
test-shellcheck:
tox run -e shellcheck
tox run -e spread-shellcheck
tox run -e lint-shellcheck

.PHONY: test-legacy-units
test-legacy-units:
tox run -e py38-withreq-legacy
tox run -e py38-legacy

.PHONY: test-units
test-units: test-legacy-units
tox run -e py38-withreq-unit
tox run -e py38-unit

.PHONY: tests
tests: tests-static test-units
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ exclude = '''
| ^/parts
| ^/stage
| ^/prime
| snapcraft_legacy
| tools
)/
'''
# Targeting future versions as well so we don't have black reformatting code
Expand Down
3 changes: 2 additions & 1 deletion requirements-devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ click==8.1.3
codespell==2.2.2
colorama==0.4.6
coverage==7.0.4
craft-archives==0.0.1
craft-cli==1.2.0
craft-grammar==1.1.1
craft-parts==1.18.1
craft-parts==1.18.3
craft-providers==1.7.2
craft-store==2.3.0
cryptography==3.4
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ cffi==1.15.1
chardet==5.1.0
charset-normalizer==2.1.1
click==8.1.3
craft-archives==0.0.1
craft-cli==1.2.0
craft-grammar==1.1.1
craft-parts==1.18.1
craft-parts==1.18.3
craft-providers==1.7.2
craft-store==2.3.0
cryptography==3.4
Expand Down
137 changes: 0 additions & 137 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,140 +40,3 @@ ignore = E203,E501
# D213 Multi-line docstring summary should start at the second line (reason: pep257 default)
ignore = D107, D203, D213
ignore_decorators = overrides

[tox:tox]
min_version = 4.0
env_list =
# Parametrized environments.
# First parameter allows us to choose Python 3.8 or 3.10.
# Second parameter chooses how to define the environment:
# withreq: using requirements-devel.txt
# noreq: Without either requirements file (but including dev requirements)
# Third parameter selects the current unit tests (unit) or the legacy unit tests (legacy)
py{38,310}-{withreq,noreq}-{unit,legacy}
skip_missing_interpreters = true
labels =
# Minimal testing environments. run with `tox run-parallel -m test`
test = py38-withreq-{unit,legacy}
# Test in Python 3.10 from an empty environment.
future-test = py310-noreq-{unit,legacy}
# Environments to run in CI
ci = py{38,310}-withreq-{unit,legacy},py{38,310}-noreq-unit
# Just run the regular unit tests, not the legacy ones
unit = py{38,310}-{withreq,noreq}-unit
# Legacy unit tests only
legacy = py{38,310}-{withreq,noreq}-legacy

[testenv]
deps =
withreq,pylint,mypy,pyright: -r{tox_root}/requirements-devel.txt
noreq: PyNaCl>=1.5.0
noreq,codespell: python-apt@git+https://salsa.debian.org/apt-team/python-apt.git@2.0.0
extras =
noreq: dev
package = wheel
set_env =
SNAPCRAFT_IGNORE_YAML_BINDINGS = 1
COVERAGE_FILE = .coverage_{env_name}

[testenv:py{38,310}-{withreq,noreq}-unit]
description = Run the unit tests
commands =
pytest {tty:--color=yes} --cov-report=xml:results/coverage-{env_name}.xml --junit-xml=results/test-results-{env_name}.xml tests/unit {posargs}

[testenv:py{38,310}-{withreq,noreq}-legacy]
description = Run the legacy unit tests
commands =
pytest {tty:--color=yes} --cov-report=xml:results/coverage-{env_name}.xml --junit-xml=results/test-results-{env_name}.xml tests/legacy/unit/ {posargs}

[testenv:format-black]
description = Autoformat with black
labels = fix
deps = black
skip_install = true
# Note: this does not include `snapcraft_legacy` as it contains several files that need reformatting.
commands = black setup.py snapcraft tests

[testenv:format-ruff]
base = ruff
description = Autoformat with ruff
labels = fix
commands =
ruff --fix setup.py snapcraft tests tools
ruff --fix --config snapcraft_legacy/ruff.toml snapcraft_legacy tests/legacy

[testenv:pylint]
description = Lint with pylint
labels = lint
# This runs all commands even if the first fails.
# Not to be confused with ignore_outcome, which turns errors into warnings.
ignore_errors = true
commands =
pylint -j 0 snapcraft
pylint -j 0 tests --disable=invalid-name,missing-module-docstring,missing-function-docstring,duplicate-code,protected-access,unspecified-encoding,too-many-public-methods,too-many-arguments,too-many-lines,redefined-outer-name

[testenv:shellcheck]
description = Check spelling with shellcheck
labels = lint
skip_install = true
allowlist_externals = bash, git
commands = bash -c "git ls-files | file --mime-type -Nnf- | grep shellscript | cut -f1 -d: | xargs shellcheck"

[testenv:spread-shellcheck]
description = Run shellcheck on spread's test.yaml files using spread-shellcheck.py
labels = lint
deps = pyyaml
skip_install = true
commands = python3 tools/spread-shellcheck.py spread.yaml tests/spread/
[testenv:mypy]
description = Run mypy
labels = type, lint
skip_install = true
commands = mypy --install-types --non-interactive .
[testenv:pyright]
description = run PyRight
labels = type, lint
allowlist_externals = pyright
commands = pyright snapcraft tests
[testenv:black]
description = run black in checking mode
skip_install = true
labels = lint
deps = black
commands = black --check --diff setup.py snapcraft tests
[testenv:codespell]
description = Check spelling with codespell
skip_install = true
labels = lint
deps = codespell
commands = codespell
[testenv:ruff]
description = Lint with ruff
skip_install = true
labels = lint
deps = ruff==0.0.220
# This runs all commands even if the first fails.
# Not to be confused with ignore_outcome, which turns errors into warnings.
ignore_errors = true
commands =
ruff --config snapcraft_legacy/ruff.toml snapcraft_legacy tests/legacy
ruff setup.py snapcraft tests tools
[testenv:isort]
description = Check import order with isort
skip_install = true
labels = lint
deps = isort
commands = isort --check .
[testenv:docstyle]
description = Check documentation style with pydocstyle
skip_install = true
labels = lint
deps = pydocstyle
commands = pydocstyle snapcraft
Loading

0 comments on commit 61b98a1

Please sign in to comment.