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

build(deps): bump craft-providers to 1.19.1 #4421

Merged
merged 1 commit into from
Oct 30, 2023
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
2 changes: 1 addition & 1 deletion requirements-devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ craft-archives==1.1.3
craft-cli==1.2.0
craft-grammar==1.1.1
craft-parts==1.19.7
craft-providers==1.10.1
craft-providers==1.19.1
craft-store==2.4.0
cryptography==40.0.2
Deprecated==1.2.13
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ craft-archives==1.1.3
craft-cli==1.2.0
craft-grammar==1.1.1
craft-parts==1.19.7
craft-providers==1.10.1
craft-providers==1.19.1
craft-store==2.4.0
cryptography==40.0.2
Deprecated==1.2.13
Expand Down
6 changes: 3 additions & 3 deletions snapcraft/commands/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import tempfile
import textwrap
from contextlib import contextmanager
from pathlib import Path
from pathlib import Path, PurePosixPath
from typing import Iterator, Optional

from craft_cli import BaseCommand, emit
Expand Down Expand Up @@ -310,7 +310,7 @@ def _install_snap(
is_dangerous = not bool(assert_file)

if assert_file:
ack_command = snap_cmd.formulate_ack_command(assert_file)
ack_command = snap_cmd.formulate_ack_command(PurePosixPath(assert_file))
emit.progress(
f"Installing assertion file with {shlex.join(ack_command)!r}."
)
Expand All @@ -328,7 +328,7 @@ def _install_snap(
install_command = snap_cmd.formulate_local_install_command(
classic=bool(snap_metadata.confinement == "classic"),
dangerous=is_dangerous,
snap_path=snap_file,
snap_path=PurePosixPath(snap_file),
)
if snap_metadata.grade == "devel":
install_command.append("--devmode")
Expand Down
3 changes: 2 additions & 1 deletion snapcraft/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from craft_cli import emit
from craft_providers import Provider, ProviderError, bases, executor
from craft_providers.actions.snap_installer import Snap
from craft_providers.lxd import LXDProvider
from craft_providers.multipass import MultipassProvider

Expand Down Expand Up @@ -199,7 +200,7 @@ def get_base_configuration(
environment=environment,
hostname=instance_name,
snaps=[
bases.buildd.Snap(
Snap(
name=snap_name,
channel=snap_channel,
classic=True,
Expand Down
18 changes: 16 additions & 2 deletions spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ backends:
# SPREAD_SYSTEM has the following format here 'ubuntu-XX.YY-64' and gets
# translated to an image XX.YY.
image=$(echo $SPREAD_SYSTEM | sed -e 's/ubuntu-\(.*\)-64/\1/')
instance_name="spread-${image}"
spread_name=$(echo ${image} | sed -e 's/\.//g')
instance_name="spread-${spread_name}"
fi

if [ -z "${image}" ]; then
Expand Down Expand Up @@ -100,7 +101,8 @@ backends:
# SPREAD_SYSTEM has the following format here 'ubuntu-XX.YY-64' and gets
# translated to an image XX.YY.
image=$(echo $SPREAD_SYSTEM | sed -e 's/ubuntu-\(.*\)-64/\1/')
instance_name="spread-${image}"
spread_name=$(echo ${image} | sed -e 's/\.//g')
instance_name="spread-${spread_name}"
fi

if [ -z "${image}" ]; then
Expand Down Expand Up @@ -254,6 +256,8 @@ prepare: |
install_snapcraft

pushd /snapcraft
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git init
git add .
git commit -m "Testing Commit"
Expand Down Expand Up @@ -309,6 +313,11 @@ suites:
systems:
- ubuntu-22.04*

tests/spread/core24/:
summary: core24 tests
systems:
- ubuntu-22.04*

# General, core suite
tests/spread/general/:
summary: tests of snapcraft core functionality
Expand All @@ -330,6 +339,11 @@ suites:
tests/spread/general/hooks/:
summary: tests of snapcraft hook functionality

tests/spread/core-devel/:
summary: tests of devel base snaps
environment:
SNAPCRAFT_BUILD_ENVIRONMENT: ""

# General, core suite
tests/spread/cross-compile/:
summary: tests of supported cross-compile functionality
Expand Down
16 changes: 16 additions & 0 deletions tests/spread/core-devel/basic/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: build-base-devel
version: '1.0'
summary: build-base-devel
description: Build a base snap with a build-base of devel
confinement: strict

type: base
build-base: devel

# grade must be devel when build-base is devel
grade: devel

parts:
build-base-devel:
plugin: nil
stage-packages: [base-files]
19 changes: 19 additions & 0 deletions tests/spread/core-devel/basic/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
summary: Test basic build for devel base

environment:
SNAPCRAFT_BUILD_ENVIRONMENT: ""

restore: |
cd "./snap"
snapcraft clean
rm -f ./*.snap
snap remove build-base-devel

execute: |
cd "./snap"

snapcraft pack

snap install --dangerous ./*.snap

grep -i "devel" /snap/build-base-devel/current/etc/os-release || { echo "Devel image not found" ; exit 1; }
11 changes: 11 additions & 0 deletions tests/spread/core24/simple-snap/snap/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- Mode: Makefile; indent-tabs-mode:t; tab-width: 4 -*-
.PHONY: all

all: hello

install: hello
install -d $(DESTDIR)/bin/
install -D $^ $(DESTDIR)/bin/

hello: hello.c
$(CC) hello.c -o hello -lcurl
6 changes: 6 additions & 0 deletions tests/spread/core24/simple-snap/snap/hello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>
#include <curl/curl.h>

int main() {
curl_global_init(CURL_GLOBAL_DEFAULT);
}
25 changes: 25 additions & 0 deletions tests/spread/core24/simple-snap/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: simple-snap
version: "1.0"
summary: Build a simple confined snap
description: |
Build a simple confined snap to test the build process.

base: core24
build-base: devel

grade: devel
confinement: strict

apps:
hello:
command: bin/hello

parts:
hello:
source: .
plugin: make
build-packages:
- gcc
- libc-dev
- libcurl4-openssl-dev
stage-packages: [libcurl4]
16 changes: 16 additions & 0 deletions tests/spread/core24/simple-snap/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
summary: Build a simple snap

environment:
SNAPCRAFT_BUILD_ENVIRONMENT: ""

restore: |
snap remove simple-snap
snapcraft clean
rm -f ./*.snap

execute: |
cd "./snap"
snapcraft pack
snap install --edge core24
snap install --dangerous ./*.snap
/snap/bin/simple-snap.hello
10 changes: 10 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,16 @@ def fake_provider(mock_instance):
class FakeProvider(Provider):
"""Fake provider."""

@property
def name(self) -> str:
"""Name of the provider."""
return "fake"

@property
def install_recommendation(self) -> str:
"""Recommended way to install the provider."""
return "snap"

def clean_project_environments(self, *, instance_name: str):
pass

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/parts/test_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import pytest
from craft_cli import EmitterMode, emit
from craft_parts import Action, Step, callbacks
from craft_providers.bases.buildd import BuilddBaseAlias
from craft_providers.bases.ubuntu import BuilddBaseAlias

from snapcraft import errors
from snapcraft.elf import ElfFile
Expand Down
13 changes: 5 additions & 8 deletions tests/unit/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import pytest
from craft_providers import ProviderError, bases
from craft_providers.actions.snap_installer import Snap
from craft_providers.lxd import LXDProvider
from craft_providers.multipass import MultipassProvider

Expand Down Expand Up @@ -212,11 +213,7 @@ def test_get_base_configuration(
compatibility_tag="snapcraft-buildd-base-v0.0",
environment="test-env",
hostname="test-instance-name",
snaps=[
bases.buildd.Snap(
name="test-snap-name", channel="test-channel", classic=True
)
],
snaps=[Snap(name="test-snap-name", channel="test-channel", classic=True)],
packages=["gnupg", "dirmngr", "git"],
)

Expand Down Expand Up @@ -259,7 +256,7 @@ def test_get_base_configuration_snap_channel(
compatibility_tag=ANY,
environment=ANY,
hostname=ANY,
snaps=[bases.buildd.Snap(name="snapcraft", channel=snap_channel, classic=True)],
snaps=[Snap(name="snapcraft", channel=snap_channel, classic=True)],
packages=ANY,
)

Expand Down Expand Up @@ -293,7 +290,7 @@ def test_get_base_configuration_snap_instance_name_default(
compatibility_tag=ANY,
environment=ANY,
hostname=ANY,
snaps=[bases.buildd.Snap(name="snapcraft", channel=None, classic=True)],
snaps=[Snap(name="snapcraft", channel=None, classic=True)],
packages=ANY,
)

Expand Down Expand Up @@ -327,7 +324,7 @@ def test_get_base_configuration_snap_instance_name_not_running_as_snap(
compatibility_tag=ANY,
environment=ANY,
hostname=ANY,
snaps=[bases.buildd.Snap(name="snapcraft", channel=None, classic=True)],
snaps=[Snap(name="snapcraft", channel=None, classic=True)],
packages=ANY,
)

Expand Down
Loading