Skip to content

Commit

Permalink
Merge pull request #3737 from snapcore/main-merge
Browse files Browse the repository at this point in the history
7.0
  • Loading branch information
sergiusens authored May 5, 2022
2 parents 8062dfd + 9140e03 commit 9a1bf8f
Show file tree
Hide file tree
Showing 766 changed files with 25,034 additions and 12,856 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you successfully run `./runtests.sh static`?
- [ ] Have you successfully run `./runtests.sh tests/unit`?
- [ ] Have you successfully run `make lint`?
- [ ] Have you successfully run `pytest tests/unit`?

-----
26 changes: 18 additions & 8 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ jobs:
run: |
# Secrets cannot be used in conditionals, so this is our dance:
# https://github.com/actions/runner/issues/520
if [[ -n "${{ secrets.STORE_LOGIN }}" ]]; then
echo "::set-output name=PUBLISH::true"
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
echo "::set-output name=PUBLISH_BRANCH::edge/pr-${{ github.event.number }}"
else
echo "::set-output name=PUBLISH_BRANCH::"
fi
if [[ -n "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}" ]]; then
echo "::set-output name=PUBLISH::env"
elif [[ -n "${{ secrets.STORE_LOGIN }}" ]]; then
echo "::set-output name=PUBLISH::legacy"
else
echo "::set-output name=PUBLISH::"
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
echo "::set-output name=PUBLISH_BRANCH::edge/pr-${{ github.event.number }}"
else
echo "::set-output name=PUBLISH_BRANCH::"
fi
Expand All @@ -43,9 +44,18 @@ jobs:
# Make sure it is installable.
sudo snap install --dangerous --classic ${{ steps.build-snapcraft.outputs.snap }}
- if: steps.decisions.outputs.PUBLISH == 'true' && steps.decisions.outputs.PUBLISH_BRANCH != null
- if: steps.decisions.outputs.PUBLISH == 'legacy' && steps.decisions.outputs.PUBLISH_BRANCH != null
uses: snapcore/action-publish@v1
with:
store_login: ${{ secrets.STORE_LOGIN }}
snap: ${{ steps.build-snapcraft.outputs.snap }}
release: ${{ steps.decisions.outputs.PUBLISH_BRANCH }}

- if: steps.decisions.outputs.PUBLISH == 'env' && steps.decisions.outputs.PUBLISH_BRANCH != null
# Use this until snapcore/action-publish#27 it is merged.
uses: sergiusens/action-publish
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
with:
snap: ${{ steps.build-snapcraft.outputs.snap }}
release: ${{ steps.decisions.outputs.PUBLISH_BRANCH }}
7 changes: 4 additions & 3 deletions .github/workflows/spread.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
spread-jobs:
- google:ubuntu-18.04-64
- google:ubuntu-20.04-64
- google:ubuntu-22.04-64

steps:
- name: Checkout snapcraft
Expand Down Expand Up @@ -84,7 +85,7 @@ jobs:
run: |
# Secrets cannot be used in conditionals, so this is our dance:
# https://github.com/actions/runner/issues/520
if [[ -n "${{ secrets.SNAP_STORE_MACAROON }}" ]]; then
if [[ -n "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS_STAGING }}" ]]; then
echo "::set-output name=RUN::true"
else
echo "::set-output name=RUN::"
Expand All @@ -107,8 +108,8 @@ jobs:
name: Run spread
env:
SPREAD_GOOGLE_KEY: ${{ secrets.SPREAD_GOOGLE_KEY }}
SNAP_STORE_MACAROON: ${{ secrets.SNAP_STORE_MACAROON }}
SNAP_STORE_CANDID_MACAROON: ${{ secrets.SNAP_STORE_CANDID_MACAROON }}
SNAPCRAFT_STORE_CREDENTIALS_STAGING: "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS_STAGING }}"
SNAPCRAFT_STORE_CREDENTIALS_STAGING_CANDID: "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS_STAGING_CANDID }}"
run: spread google:ubuntu-18.04-64:tests/spread/general/store

- name: Discard spread workers
Expand Down
65 changes: 58 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,89 @@
name: Python Environment Tests
on: [pull_request, push]
on:
push:
branches:
- "main"
- "snapcraft/7.0"
- "release/*"
pull_request:

jobs:
static-and-unit-tests:
linters:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |
./tools/environment-setup-local.sh
sudo apt update
sudo apt install -y libapt-pkg-dev libyaml-dev xdelta3 shellcheck
pip install -U -r requirements.txt -r requirements-devel.txt
pip install .
- name: Run black
run: |
make test-black
- name: Run codespell
run: |
source ${HOME}/.venv/snapcraft/bin/activate
make test-codespell
- name: Run flake8
run: |
source ${HOME}/.venv/snapcraft/bin/activate
make test-flake8
- name: Run isort
run: |
make test-isort
- name: Run mypy
run: |
source ${HOME}/.venv/snapcraft/bin/activate
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
env:
SNAPCRAFT_IGNORE_YAML_BINDINGS: "1"
run: |
make test-pylint
- name: Run shellcheck
run: |
make test-shellcheck
tests:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.10"]

runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y libapt-pkg-dev libyaml-dev xdelta3 shellcheck
pip install -U wheel setuptools pip
pip install -U -r requirements.txt -r requirements-devel.txt
pip install .
- name: Run unit tests
env:
SNAPCRAFT_IGNORE_YAML_BINDINGS: "1"
run: |
source ${HOME}/.venv/snapcraft/bin/activate
make test-units
- name: Upload code coverage
uses: codecov/codecov-action@v1
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ docs/reference.md
htmlcov
.idea
.mypy_cache
parts
/parts
pip-wheel-metadata/
prime
*.pyc
Expand All @@ -27,7 +27,6 @@ snap/.snapcraft/
stage
*.swp
target
tests/unit/parts/
tests/unit/snap/
tests/unit/stage/
.vscode
40 changes: 33 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,65 @@
SOURCES=setup.py snapcraft tests/*.py tests/unit

.PHONY: autoformat-black
autoformat-black:
black .
black $(SOURCES)

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

.PHONY: test-black
test-black:
black --check --diff .
black --check --diff $(SOURCES)

.PHONY: test-codespell
test-codespell:
codespell --quiet-level 4 --ignore-words-list crate,keyserver --skip '*.tar,*.xz,*.zip,*.bz2,*.7z,*.gz,*.deb,*.rpm,*.snap,*.gpg,*.pyc,*.png,*.ico,*.jar,changelog,.git,.hg,.mypy_cache,.tox,.venv,_build,buck-out,__pycache__,build,dist,.vscode,parts,stage,prime,test_appstream.py,./snapcraft.spec,./.direnv,./.pytest_cache'
codespell --quiet-level 4 --ignore-words-list crate,keyserver,comandos --skip '*.tar,*.xz,*.zip,*.bz2,*.7z,*.gz,*.deb,*.rpm,*.snap,*.gpg,*.pyc,*.png,*.ico,*.jar,*.so,changelog,.git,.hg,.mypy_cache,.tox,.venv,_build,buck-out,__pycache__,build,dist,.vscode,parts,stage,prime,test_appstream.py,./snapcraft.spec,./.direnv,./.pytest_cache'

.PHONY: test-flake8
test-flake8:
python3 -m flake8 .
python3 -m flake8 $(SOURCES)

.PHONY: test-isort
test-isort:
isort --check $(SOURCES)

.PHONY: test-mypy
test-mypy:
mypy .
mypy $(SOURCES)

.PHONY: test-pydocstyle
test-pydocstyle:
pydocstyle snapcraft

.PHONY: test-pylint
test-pylint:
pylint snapcraft
pylint tests/*.py tests/unit --disable=invalid-name,missing-module-docstring,missing-function-docstring,no-self-use,duplicate-code,protected-access,unspecified-encoding,too-many-public-methods,too-many-arguments

.PHONY: test-pyright
test-pyright:
pyright $(SOURCES)

.PHONY: test-shellcheck
test-shellcheck:
# Skip third-party gradlew script.
find . \( -name .git -o -name gradlew \) -prune -o -print0 | xargs -0 file -N | grep shell.script | cut -f1 -d: | xargs shellcheck
./tools/spread-shellcheck.py spread.yaml tests/spread/

.PHONY: test-legacy-units
test-legacy-units:
pytest --cov-report=xml --cov=snapcraft tests/legacy/unit

.PHONY: test-units
test-units:
test-units: test-legacy-units
pytest --cov-report=xml --cov=snapcraft tests/unit

.PHONY: tests
tests: tests-static test-units

.PHONY: tests-static
tests-static: test-black test-codespell test-flake8 test-mypy test-shellcheck
tests-static: test-black test-codespell test-flake8 test-isort test-mypy test-pydocstyle test-pyright test-pylint test-shellcheck

.PHONY: lint
lint: tests-static
5 changes: 2 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ environment:
TIMESTAMP_SERVICE: http://timestamp.digicert.com

matrix:
- PYTHON: C:\Python37-x64
- PYTHON: C:\Python38-x64

cache:
- '%LOCALAPPDATA%\pip\Cache\http'
Expand All @@ -27,7 +27,7 @@ build_script:
- cmd: |
echo "Building snapcraft.exe..."
venv\Scripts\activate.bat
pyinstaller.exe --onefile snapcraft.spec
pyinstaller.exe --copy-metadata lazr.restfulclient --onefile snapcraft.spec
venv\Scripts\deactivate.bat
echo "Test signing snapcraft.exe..."
Expand Down Expand Up @@ -58,7 +58,6 @@ build_script:
test_script:
- cmd: |
echo "Smoke testing snapcraft.exe..."
dist\snapcraft.exe logout
dist\snapcraft.exe version
mkdir test
cd test
Expand Down
4 changes: 2 additions & 2 deletions bin/snapcraftctl
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ quote()
python3_command="${SNAPCRAFT_INTERPRETER:-$(command -v python3)}"

snapcraftctl_command="$python3_command -I -c '
import snapcraft.cli.__main__
import snapcraft_legacy.cli.__main__
# Click strips off the first arg by default, so the -c will not be passed
snapcraft.cli.__main__.run_snapcraftctl(prog_name=\"snapcraftctl\")
snapcraft_legacy.cli.__main__.run_snapcraftctl(prog_name=\"snapcraftctl\")
'"

snapcraftctl_args=$(quote "$@")
Expand Down
20 changes: 20 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,23 @@ force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 88

[tool.pylint.messages_control]
# duplicate-code can't be disabled locally: https://github.com/PyCQA/pylint/issues/214
disable = "too-few-public-methods,fixme,use-implicit-booleaness-not-comparison,duplicate-code"

[tool.pylint.format]
max-attributes = 15
max-args = 6
good-names = "id"

[tool.pylint.MASTER]
extension-pkg-allow-list = [
"lxml.etree",
"pydantic",
"pytest",
]
load-plugins = "pylint_fixme_info,pylint_pytest"

[tool.pylint.SIMILARITIES]
min-similarity-lines=10
Loading

0 comments on commit 9a1bf8f

Please sign in to comment.