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

chore: remove travis and autopkgtest #5073

Merged
merged 4 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
78 changes: 0 additions & 78 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ tox run -e lint-codespell

## Evaluating pull requests

Oftentimes all you want to do is see if a given pull request solves the issue you were having. To make this easier, the Travis CI setup for snapcraft _publishes_ the resulting snap that was built for x86-64 using `transfer.sh`.
To download the snap, find the relevant CI job run for the PR under review and locate the "snap" stage, the URL to download from will be located at the end of logs for that job.
Oftentimes all you want to do is see if a given pull request solves the issue you were having. To make this easier, a snap is published for `amd64` on a channel named `latest/edge/pr-<PR number>` where `PR number` is the number of the pull request.

For feature branches, a snap is published for `amd64` on a channel named `latest/edge/<branch name>`. For example, a branch named `feature/offline-mode` would be available on the channel `latest/edge/offline-mode`.

## Reaching out

Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[![snapcraft](https://snapcraft.io/snapcraft/badge.svg)](https://snapcraft.io/snapcraft)
[![Build Status][travis-image]][travis-url]
[![Documentation Status](https://readthedocs.com/projects/canonical-snapcraft/badge/?version=latest)](https://canonical-snapcraft.readthedocs-hosted.com/en/latest/?badge=latest)
[![Scheduled spread tests](https://github.com/canonical/snapcraft/actions/workflows/spread-scheduled.yaml/badge.svg?branch=main)](https://github.com/canonical/snapcraft/actions/workflows/spread-scheduled.yaml)
[![Coverage Status][codecov-image]][codecov-url]
Expand Down Expand Up @@ -29,8 +28,5 @@ Learn about the latest features by following Snapcraft on
We love contributors. Read the [hacking guide](HACKING.md) if you're interested in helping out.


[travis-image]: https://travis-ci.org/canonical/snapcraft.svg?branch=master
[travis-url]: https://travis-ci.org/canonical/snapcraft

[codecov-image]: https://codecov.io/github/canonical/snapcraft/coverage.svg?branch=master
[codecov-url]: https://codecov.io/github/canonical/snapcraft?branch=master
37 changes: 0 additions & 37 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ These tests are in the `tests/integration` directory, with the `snapcraft.yamls`
At any time, an integration test may fail and given the use of temporary directories it can be hard to inspect what went on. When working on a specific test case you can set the environment variable `SNAPCRAFT_TEST_KEEP_DATA_PATH` to a directory path for the sepecic test.
This mechanism will only work when working with individual tests and will fail to run with a batch of them.

### Slow tests

Some tests take too long. This affects the pull requests because we have to wait for a long time, and they will make Travis CI timeout because we have only 50 minutes per suite in there. The solution is to tag these tests as slow, and don't run them in all pull requests. These tests will only be run in autopkgtests.

To mark a test case as slow, set the class attribute `slow_test = True`.

To run all the tests, including the slow ones, set the environment variable `SNAPCRAFT_SLOW_TESTS=1`.

### Snaps tests

The snaps tests is a suite of high-level tests that try to simulate real-world scenarios of a user interacting with snapcraft. They cover the call to snapcraft to generate a snap file from the source files of a fully functional project, the installation of the resulting snap, and the execution of the binaries and services of this snap.
Expand Down Expand Up @@ -120,35 +112,6 @@ We can currently run a minimal subset of snapcraft integration tests on macOS. T

For manual exploratory testing, the team has one mac machine available.

## Autopkgtests for the snapcraft deb

Autopkgtests are tests for the project packaged as a deb. The unit tests are run during autopkgtests while the snapcraft deb is being built. Then the resulting deb is installed, and the integration and snaps suites are executed using the installed snapcraft.


### How to run on Xenial

The easiest way is to use a LXC container. From the root of the project, run:

sudo apt install autopkgtest
adt-run --unbuilt-tree . --apt-upgrade --- lxd ubuntu:xenial

It's possible to select only one of the suites using `--testname`, for example:

adt-run --unbuilt-tree . --apt-upgrade --testname=integrationtests --- lxd ubuntu:xenial


### How to run on Bionic

The easiest way is to use a LXC container. From the root of the project, run:

sudo apt install autopkgtest
autopkgtest . -U -- lxd ubuntu:xenial

It's possible to select only one of the suites using `--test-name`, for example:

autopkgtest . -U --test-name=integrationtests-spread -- lxd ubuntu:xenial


## Spread tests for the snapcraft snap

[Spread](https://github.com/canonical/spread) is a system to distribute tests and execute them in different backends, in parallel. We are currently using spread only to run the integration suite using the installed snapcraft snap from the edge channel.
Expand Down
10 changes: 1 addition & 9 deletions snapcraft/store/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
from ._legacy_account import LegacyUbuntuOne
from .onprem_client import ON_PREM_ENDPOINTS, OnPremClient

_TESTING_ENV_PREFIXES = ["TRAVIS", "AUTOPKGTEST_TMP"]
mr-cal marked this conversation as resolved.
Show resolved Hide resolved

_POLL_DELAY = 1
_HUMAN_STATUS = {
"being_processed": "processing",
Expand All @@ -51,13 +49,7 @@ def build_user_agent(
os_platform: utils.OSPlatform = utils.get_os_platform(), # noqa: B008
):
"""Build Snapcraft's user agent."""
if any(
key.startswith(prefix) for prefix in _TESTING_ENV_PREFIXES for key in os.environ
):
testing = " (testing) "
else:
testing = " "
return f"snapcraft/{version}{testing}{os_platform!s}"
return f"snapcraft/{version} {os_platform!s}"


def use_candid() -> bool:
Expand Down
14 changes: 1 addition & 13 deletions snapcraft_legacy/storeapi/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os
import sys

import snapcraft_legacy
Expand All @@ -23,16 +22,6 @@
from snapcraft_legacy.internal.errors import OsReleaseNameError, OsReleaseVersionIdError


def _is_ci_env():
env_prefixes = ["TRAVIS", "AUTOPKGTEST_TMP"]
matches = []

for prefix in env_prefixes:
matches += [var for var in os.environ.keys() if var.startswith(prefix)]

return len(matches) > 0


def _get_linux_release(release: os_release.OsRelease) -> str:
try:
os_name = release.name()
Expand All @@ -48,11 +37,10 @@ def _get_linux_release(release: os_release.OsRelease) -> str:

def get_user_agent(platform: str = sys.platform) -> str:
arch = project.Project().deb_arch
testing = "(testing) " if _is_ci_env() else ""

if platform == "linux":
os_platform = _get_linux_release(os_release.OsRelease())
else:
os_platform = platform.title()

return f"snapcraft/{snapcraft_legacy.__version__} {testing}{os_platform} ({arch})"
return f"snapcraft/{snapcraft_legacy.__version__} {os_platform} ({arch})"
47 changes: 0 additions & 47 deletions spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,51 +121,6 @@ backends:
username: root
password: ubuntu

autopkgtest:
type: adhoc
allocate: |
echo "Allocating ad-hoc $SPREAD_SYSTEM"
if [ -z "${ADT_ARTIFACTS:-}" ]; then
FATAL "adhoc only works inside autopkgtest"
exit 1
fi
echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/99-spread-users
ADDRESS localhost:22
discard: echo "Discarding ad-hoc $SPREAD_SYSTEM"
systems:
# Focal
- ubuntu-20.04-amd64:
username: ubuntu
password: ubuntu
- ubuntu-20.04-ppc64el:
username: ubuntu
password: ubuntu
- ubuntu-20.04-armhf:
username: ubuntu
password: ubuntu
- ubuntu-20.04-s390x:
username: ubuntu
password: ubuntu
- ubuntu-20.04-arm64:
username: ubuntu
password: ubuntu
# Jammy
- ubuntu-22.04-amd64:
username: ubuntu
password: ubuntu
- ubuntu-22.04-ppc64el:
username: ubuntu
password: ubuntu
- ubuntu-22.04-armhf:
username: ubuntu
password: ubuntu
- ubuntu-22.04-s390x:
username: ubuntu
password: ubuntu
- ubuntu-22.04-arm64:
username: ubuntu
password: ubuntu

exclude: [snaps-cache/]

prepare: |
Expand Down Expand Up @@ -342,14 +297,12 @@ suites:
- ubuntu-20.04-64
- ubuntu-22.04-64
kill-timeout: 180m
warn-timeout: 9m # Keep less than 10 minutes so Travis can't timeout
priority: 90 # Run this test relatively early since fetching images can take time
tests/spread/providers/legacy/:
summary: tests of snapcraft using build providers
systems:
- ubuntu-20.04-64
kill-timeout: 180m
warn-timeout: 9m # Keep less than 10 minutes so Travis can't timeout
priority: 90 # Run this test relatively early since fetching images can take time

# Plugin-specific suites
Expand Down
26 changes: 0 additions & 26 deletions tests/legacy/unit/store/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os

import fixtures
from testtools.matchers import Equals

from snapcraft_legacy import ProjectOptions
Expand Down Expand Up @@ -54,27 +52,3 @@ def test_user_agent_darwin(self):
expected = f"snapcraft/{snapcraft_version} Darwin ({arch})"

self.expectThat(agent.get_user_agent(platform="darwin"), Equals(expected))

def test_in_travis_ci_env(self):
self.useFixture(fixtures.EnvironmentVariable("TRAVIS_TESTING", "1"))

self.assertTrue(agent._is_ci_env())

def test_in_autopkgtest_ci_env(self):
self.useFixture(fixtures.EnvironmentVariable("AUTOPKGTEST_TMP", "1"))

self.assertTrue(agent._is_ci_env())

def test_not_in_ci_env(self):
# unset any known testing environment vars
testing_vars = ["TRAVIS", "AUTHPKGTEST_TMP"]
vars_to_unset = []
for env_var in os.environ:
for test_var in testing_vars:
if env_var.startswith(test_var):
vars_to_unset.append(env_var)

for var in vars_to_unset:
self.useFixture(fixtures.EnvironmentVariable(var, None))

self.assertFalse(agent._is_ci_env())
7 changes: 1 addition & 6 deletions tests/spread/general/package-repositories/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ execute: |
cd "$SNAP"

# Build what we have.
# We cannot use --use-lxd for autopkgtest so we resort to --destructive-mode there.
if [ "$SPREAD_SYSTEM" = "ubuntu-20.04-64" ]; then
snapcraft --use-lxd
else
snapcraft --destructive-mode
fi
snapcraft --use-lxd

# And verify the snap runs as expected.
snap install "${SNAP}"_1.0_*.snap --dangerous
Expand Down
1 change: 0 additions & 1 deletion tests/spread/plugins/v2/colcon-ros2-daemon/task.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
summary: Build and run a basic daemon colcon snap
warn-timeout: 9m # Keep less than 10 minutes so Travis can't timeout
priority: 100 # Run this test early so we're not waiting for it

environment:
Expand Down
24 changes: 0 additions & 24 deletions tests/unit/store/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,30 +219,6 @@ def test_useragent_linux():
)


@pytest.mark.parametrize("testing_env", ("TRAVIS_TESTING", "AUTOPKGTEST_TMP"))
def test_useragent_linux_with_testing(monkeypatch, testing_env):
"""Construct a user-agent as a patched Linux machine"""
monkeypatch.setenv(testing_env, "1")
os_platform = OSPlatform(
system="Arch Linux", release="5.10.10-arch1-1", machine="x86_64"
)

assert client.build_user_agent(version="7.1.0", os_platform=os_platform) == (
"snapcraft/7.1.0 (testing) Arch Linux/5.10.10-arch1-1 (x86_64)"
)


@pytest.mark.parametrize("testing_env", ("TRAVIS_TESTING", "AUTOPKGTEST_TMP"))
def test_useragent_windows_with_testing(monkeypatch, testing_env):
"""Construct a user-agent as a patched Windows machine"""
monkeypatch.setenv(testing_env, "1")
os_platform = OSPlatform(system="Windows", release="10", machine="AMD64")

assert client.build_user_agent(version="7.1.0", os_platform=os_platform) == (
"snapcraft/7.1.0 (testing) Windows/10 (AMD64)"
)


#####################
# Store Environment #
#####################
Expand Down
5 changes: 1 addition & 4 deletions tools/brew_install_from_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ def main():

def download_snapcraft_source(dest_dir):
dest_file = os.path.join(dest_dir, "snapcraft-0.1.tar.gz")
branch_source = "https://github.com/{}/archive/{}.tar.gz".format(
os.environ.get("TRAVIS_PULL_REQUEST_SLUG") or "canonical/snapcraft",
os.environ.get("TRAVIS_PULL_REQUEST_BRANCH") or "main",
)
branch_source = "https://github.com/canonical/snapcraft/archive/main.tar.gz"
print("Downloading branch source from {}".format(branch_source))
urllib.request.urlretrieve(branch_source, dest_file) # noqa S310
return dest_file
Expand Down
Loading
Loading