Skip to content
Draft
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
43 changes: 39 additions & 4 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,39 @@ on:
- main

jobs:
build-snapd-deb:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
repository: 'valentindavid/snapd'
path: snapd
ref: 'valentindavid/udev-scan-disk'
- name: Build snapd deb
working-directory: '${{ github.workspace }}/snapd'
run: |
sudo apt update
sudo DEBIAN_FRONTEND=noninteractive apt build-dep -yqq --no-install-recommends ./
bash get-deps.sh
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc
- uses: actions/upload-artifact@v4
with:
name: snapd
path: "${{ github.workspace }}/snapd_*.deb"

build:
runs-on: [ self-hosted, spread-enabled ]
needs: build-snapd-deb
steps:
- name: Cleanup job workspace
id: cleanup-job-workspace
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: snapd

- name: Build snap
run: |
Expand All @@ -41,14 +65,19 @@ jobs:

tests-main:
runs-on: [ self-hosted, spread-enabled ]
needs: build
needs:
- build
- build-snapd-deb
steps:
- name: Cleanup job workspace
id: cleanup-job-workspace
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: snapd
- uses: actions/download-artifact@v4
with:
name: snaps
Expand All @@ -66,7 +95,9 @@ jobs:
done
tests-snapd:
runs-on: ubuntu-latest
needs: build
needs:
- build
- build-snapd-deb
steps:
- name: Cleanup job workspace
id: cleanup-job-workspace
Expand All @@ -79,8 +110,12 @@ jobs:
path: core-initrd
- uses: actions/checkout@v4
with:
repository: 'snapcore/snapd'
repository: 'valentindavid/snapd'
path: snapd
ref: 'valentindavid/udev-scan-disk'
- uses: actions/download-artifact@v4
with:
name: snapd
- uses: actions/download-artifact@v4
with:
name: snaps
Expand All @@ -94,7 +129,7 @@ jobs:
. "core-initrd/tests/lib/prepare-utils.sh"

echo "************* INSTALLING DEPS *************"
install_core_initrd_deps '${{ github.workspace }}/core-initrd'
install_core_initrd_deps '${{ github.workspace }}/core-initrd' '${{ github.workspace }}'/snapd_*.deb

echo "************* DOWNLOADING SNAPS *************"
download_core_initrd_snaps 'edge'
Expand Down
3 changes: 3 additions & 0 deletions factory/usr/lib/systemd/system/snap-initramfs-mounts.service
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Before=initrd-root-device.target
Wants=dbus.socket
After=dbus.socket

BindsTo=dev-ubuntu-disk.device
After=dev-ubuntu-disk.device

[Service]
Type=oneshot
RemainAfterExit=true
Expand Down
15 changes: 15 additions & 0 deletions factory/usr/lib/udev/rules.d/90-ubuntu-core-partitions.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SUBSYSTEM!="block", GOTO="ubuntu_core_partitions_end"

ENV{DEVTYPE}=="partition", IMPORT{parent}="UBUNTU_*_UUID"
IMPORT{program}="/usr/lib/snapd/snap-bootstrap scan-disk"
ENV{DEVTYPE}=="disk", ENV{UBUNTU_DISK}=="1", SYMLINK+="ubuntu/disk"
ENV{DEVTYPE}=="partition", ENV{UBUNTU_SEED}=="1", SYMLINK+="ubuntu/seed"
ENV{DEVTYPE}=="partition", ENV{UBUNTU_BOOT}=="1", SYMLINK+="ubuntu/boot"
ENV{DEVTYPE}=="partition", ENV{UBUNTU_DATA}=="1", ENV{ID_FS_TYPE}=="crypto_LUKS", SYMLINK+="ubuntu/data-luks"
ENV{DEVTYPE}=="partition", ENV{UBUNTU_DATA}=="1", ENV{ID_FS_TYPE}!="crypto_LUKS", SYMLINK+="ubuntu/data"
ENV{DEVTYPE}=="partition", ENV{UBUNTU_SAVE}=="1", ENV{ID_FS_TYPE}=="crypto_LUKS", SYMLINK+="ubuntu/save-luks"
ENV{DEVTYPE}=="partition", ENV{UBUNTU_SAVE}=="1", ENV{ID_FS_TYPE}!="crypto_LUKS", SYMLINK+="ubuntu/save"
ENV{DM_UUID}=="CRYPT-*", ENV{DM_NAME}=="ubuntu-data-*", SYMLINK+="ubuntu/data"
ENV{DM_UUID}=="CRYPT-*", ENV{DM_NAME}=="ubuntu-save-*", SYMLINK+="ubuntu/save"

LABEL="ubuntu_core_partitions_end"
2 changes: 1 addition & 1 deletion tests/lib/prepare-uc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -x
. "$TESTSLIB/prepare-utils.sh"

# install dependencies
install_core_initrd_deps "$PROJECT_PATH"
install_core_initrd_deps "$PROJECT_PATH" "$PROJECT_PATH"/snapd_*.deb

# TODO: is this still necessary for core-initrd? (this was copied from snapd)
# create test user for spread to use
Expand Down
8 changes: 7 additions & 1 deletion tests/lib/prepare-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ start_snapd_core_vm() {

install_core_initrd_deps() {
local project_dir="$1"
if [ -n "${2-}" ]; then
snapd_deb="$(realpath "$2")"
else
snapd_deb=snapd
fi

# needed for dracut which is a build-dep of ubuntu-core-initramfs
# and for the version of snapd here which we want to use to pull snap-bootstrap
Expand All @@ -128,7 +133,8 @@ install_core_initrd_deps() {

# these are already installed in the lxd image which speeds things up, but they
# are missing in qemu and google images.
sudo DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -o Dpkg::Options::="--force-confnew" psmisc fdisk snapd mtools ovmf qemu-system-x86 sshpass whois openssh-server -yqq
sudo DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -o Dpkg::Options::="--force-confnew" psmisc fdisk mtools ovmf qemu-system-x86 sshpass whois openssh-server -yqq
sudo DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends --allow-downgrades "${snapd_deb}" -yqq

# use the snapd snap explicitly
# TODO: since ubuntu-image ships it's own version of `snap prepare-image`,
Expand Down
2 changes: 1 addition & 1 deletion tests/spread/build/build-initrd/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ prepare: |
. "$TESTSLIB/prepare-utils.sh"

# install dependencies
install_core_initrd_deps "$PROJECT_PATH"
install_core_initrd_deps "$PROJECT_PATH" "$PROJECT_PATH"/snapd_*.deb

# download pc-kernel and pc gadget
# FIXME: switch to 24 channel when available
Expand Down