Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into hotfix/7.2-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiusens committed Feb 23, 2023
2 parents 524866d + 4e50340 commit de8e45a
Show file tree
Hide file tree
Showing 216 changed files with 4,290 additions and 601 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,14 @@ jobs:
fi
- if: steps.decisions.outputs.PUBLISH == 'true'
name: Remove Docker
run: |
# https://github.com/canonical/lxd-cloud/blob/f20a64a8af42485440dcbfd370faf14137d2f349/test/includes/lxd.sh#L13-L23
sudo rm -rf /etc/docker
sudo apt-get purge moby-buildx moby-engine moby-cli moby-compose moby-containerd moby-runc -y
sudo iptables -P FORWARD ACCEPT
- if: steps.decisions.outputs.PUBLISH == 'true'
name: Checkout Snapcraft
name: Checkout Snapcraft
uses: actions/checkout@v2
with:
# Fetch all of history so Snapcraft can determine its own version from git.
fetch-depth: 0

- if: steps.decisions.outputs.PUBLISH == 'true'
uses: snapcore/action-build@v1.0.9
uses: snapcore/action-build@v1
name: Build Snapcraft Snap
id: build
with:
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/spread.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,9 @@ jobs:
with:
fetch-depth: 0

- name: Remove Docker
run: |
# https://github.com/canonical/lxd-cloud/blob/f20a64a8af42485440dcbfd370faf14137d2f349/test/includes/lxd.sh#L13-L23
sudo rm -rf /etc/docker
sudo apt-get purge moby-buildx moby-engine moby-cli moby-compose moby-containerd moby-runc -y
sudo iptables -P FORWARD ACCEPT
- name: Build snapcraft snap
id: build-snapcraft
uses: snapcore/action-build@v1.0.9
uses: snapcore/action-build@v1

- name: Upload snapcraft snap
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -53,6 +47,7 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true

- name: Download snapcraft snap
uses: actions/download-artifact@v2
Expand Down Expand Up @@ -102,6 +97,7 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true

- if: steps.decisions.outputs.RUN == 'true'
name: Download snapcraft snap
Expand Down
90 changes: 0 additions & 90 deletions .github/workflows/tests.yaml

This file was deleted.

89 changes: 89 additions & 0 deletions .github/workflows/tox.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Tox
on:
push:
branches:
- "main"
- "snapcraft/7.0"
- "release/*"
- "hotfix/*"
pull_request:

jobs:
linters:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
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::apt-get update"
sudo apt-get update
echo "::endgroup::"
echo "::group::apt-get install..."
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
echo "::endgroup::"
echo "::group::Create virtual environments for linting processes."
tox run-parallel --parallel all --parallel-no-spinner -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 -m lint
tests:
strategy:
fail-fast: false # Run all the tests to their conclusions.
matrix:
platform: [ubuntu-20.04, ubuntu-22.04]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python versions on ${{ matrix.platform }}
uses: actions/setup-python@v4
with:
python-version: |
3.8
3.10
- name: Install dependencies
run: |
echo "::group::apt-get update"
sudo apt-get update
echo "::endgroup::"
echo "::group::apt-get install..."
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
echo "::endgroup::"
mkdir -p results
- name: Setup Tox environments
run: tox run-parallel --parallel auto --parallel-no-spinner --parallel-live -m ci --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
- name: Upload code coverage
uses: codecov/codecov-action@v3
with:
directory: ./results/
files: coverage*.xml
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results-${{ matrix.platform }}
path: results/
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
build
Cargo.lock
.coverage**
coverage-*
demos/*/parts/
demos/*/prime/
demos/**/*.snap
Expand All @@ -21,6 +22,7 @@ pip-wheel-metadata/
prime
*.pyc
__pycache__
.pytest_cache
*.snap
snap/.snapcraft/
.spread-reuse.*
Expand All @@ -29,6 +31,8 @@ stage
target
tests/unit/snap/
tests/unit/stage/
test-results*
.tox
.vscode
venv
.venv
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "docs"]
path = docs
url = https://github.com/CanonicalLtd/snappy-docs.git
[submodule "tests/spread/tools/snapd-testing-tools"]
path = tests/spread/tools/snapd-testing-tools
url = https://github.com/snapcore/snapd-testing-tools.git
16 changes: 8 additions & 8 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

## Setting up a development environment

We want to make sure everyone develops using a consistent base, to ensure that these instructions rely on LXD (use whatever is convenient as long as you do not stray away from an Ubuntu 16.04 LTS base)
We want to make sure everyone develops using a consistent base, to ensure that these instructions rely on LXD (use whatever is convenient as long as you do not stray away from an Ubuntu LTS base)

Clone these sources and make it your working directory:
Clone the snapcraft repository and its submodules and make it your working directory:

```
git clone https://github.com/snapcore/snapcraft.git
```shell
git clone https://github.com/snapcore/snapcraft.git --recurse-submodules
cd snapcraft
```

If you already have LXD setup you can skip this part, if not, run:

```
```shell
sudo snap install lxd
sudo lxd init --auto --storage-backend=dir
sudo adduser "$USER" lxd
Expand All @@ -22,17 +22,17 @@ newgrp lxd

Setup the environment by running:

```
```shell
./tools/environment-setup.sh
```

To work inside this environment, run:

```
```shell
lxc exec snapcraft-dev -- sudo -iu ubuntu bash
```

Import your keys (`ssh-import-id`) and add a `Host` entry to your ssh config if you are interested in [Code's](https://snapcraft.io/code) [Remote-SSH]() plugin.
Import your keys (`ssh-import-id`) and add a `Host` entry to your ssh config if you are interested in [Code's](https://snapcraft.io/code) [Remote-SSH](https://code.visualstudio.com/docs/remote/ssh) plugin.

### Testing

Expand Down
37 changes: 18 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,63 @@ SOURCES_LEGACY=snapcraft_legacy tests/legacy

.PHONY: autoformat-black
autoformat-black:
black $(SOURCES) $(SOURCES_LEGACY)
tox run -e format

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

.PHONY: test-black
test-black:
black --check --diff $(SOURCES) $(SOURCES_LEGACY)
tox run -e black

.PHONY: test-codespell
test-codespell:
codespell --quiet-level 4 --ignore-words-list crate,keyserver,comandos,ro --skip '*.tar,*.xz,*.zip,*.bz2,*.7z,*.gz,*.deb,*.rpm,*.snap,*.gpg,*.pyc,*.png,*.ico,*.jar,*.so,changelog,.git,.hg,.mypy_cache,.tox,.venv,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 $(SOURCES) $(SOURCES_LEGACY)
tox run -e codespell

.PHONY: test-isort
test-isort:
isort --check $(SOURCES) $(SOURCES_LEGACY)
tox run -e isort

.PHONY: test-mypy
test-mypy:
mypy $(SOURCES)
tox run -e mypy

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

.PHONY: test-pylint
test-pylint:
pylint snapcraft
pylint tests/*.py tests/unit --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
tox run -e pylint

.PHONY: test-pyright
test-pyright:
pyright $(SOURCES)
tox run -e pyright

.PHONY: test-ruff
test-ruff:
ruff --config snapcraft_legacy/ruff.toml $(SOURCES_LEGACY)
ruff $(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/
tox run -e shellcheck
tox run -e spread-shellcheck

.PHONY: test-legacy-units
test-legacy-units:
pytest --cov-report=xml --cov=snapcraft tests/legacy/unit
tox run -e py38-withreq-legacy

.PHONY: test-units
test-units: test-legacy-units
pytest --cov-report=xml --cov=snapcraft tests/unit
tox run -e py38-withreq-unit

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

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

.PHONY: lint
lint: tests-static
Loading

0 comments on commit de8e45a

Please sign in to comment.