Skip to content

Commit

Permalink
tests(remotebuild): add per-base remote-build spread tests
Browse files Browse the repository at this point in the history
Signed-off-by: Callahan Kovacs <[email protected]>
  • Loading branch information
mr-cal committed Jul 3, 2024
1 parent 4627e22 commit d04c205
Show file tree
Hide file tree
Showing 27 changed files with 309 additions and 141 deletions.
44 changes: 7 additions & 37 deletions .github/workflows/spread-scheduled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,44 +51,9 @@ jobs:
run: |
spread google:ubuntu-22.04-64:tests/spread/plugins/${{ matrix.type }}/kernel
remote-build-core24:
runs-on: [spread-installed]
needs: [snap-build]
strategy:
fail-fast: false
matrix:
system:
- ubuntu-24.04-64
steps:
- name: Cleanup job workspace
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
- name: Checkout snapcraft
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Download snap artifact
uses: actions/download-artifact@v4
with:
name: snap
path: tests
- name: remote-build test
env:
LAUNCHPAD_TOKEN: "${{ secrets.LAUNCHPAD_TOKEN }}"
run: |
spread google:${{ matrix.system }}:tests/spread/core24/remote-build
remote-build:
runs-on: [spread-installed]
needs: [snap-build]
strategy:
fail-fast: false
matrix:
system:
- ubuntu-22.04-64
- fedora-39-64
steps:
- name: Cleanup job workspace
run: |
Expand All @@ -108,5 +73,10 @@ jobs:
env:
LAUNCHPAD_TOKEN: "${{ secrets.LAUNCHPAD_TOKEN }}"
run: |
spread google:${{ matrix.system }}:tests/spread/general/remote-build
spread google:${{ matrix.system }}:tests/spread/core24/remote-build
spread google:ubuntu-20.04-64:tests/spread/core20/remote-build-legacy
spread google:ubuntu-22.04-64:tests/spread/core22/remote-build-legacy
spread google:ubuntu-22.04-64:tests/spread/core22/remote-build
spread google:ubuntu-24.04-64:tests/spread/core24/remote-build
# smoketest fedora with a single remote-build test
spread google:fedora-39-64:tests/spread/core24/remote-build:no-platforms
5 changes: 5 additions & 0 deletions spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ restore-each: |
"$TOOLS_DIR"/restore.sh
suites:
tests/spread/core20/:
summary: core20 specific tests
systems:
- ubuntu-20.04*

tests/spread/core22/:
summary: core22 specific tests
systems:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test-snap-all-core20_1.0_all.snap
16 changes: 16 additions & 0 deletions tests/spread/core20/remote-build-legacy/snaps/all/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: test-snap-all-core20
base: core20
version: "1.0"
summary: Test snap for remote build
description: Test snap for remote build

grade: stable
confinement: strict

architectures:
- build-on: [amd64]
run-on: [all]

parts:
my-part:
plugin: nil
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test-snap-architectures-core20_1.0_amd64.snap
test-snap-architectures-core20_1.0_arm64.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: test-snap-architectures-core20
base: core20
version: "1.0"
summary: Test snap for remote build
description: Test snap for remote build

grade: stable
confinement: strict

architectures:
- build-on: [amd64]
run-on: [amd64]
- build-on: [arm64]
run-on: [arm64]

parts:
my-part:
plugin: nil
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test-snap-no-architectures-core20_1.0_amd64.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: test-snap-no-architectures-core20
base: core20
version: "1.0"
summary: Test snap for remote build
description: Test snap for remote build

grade: stable
confinement: strict

parts:
my-part:
plugin: nil
60 changes: 60 additions & 0 deletions tests/spread/core20/remote-build-legacy/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
summary: Test the legacy remote builder for core20
manual: true
kill-timeout: 180m

environment:
LAUNCHPAD_TOKEN: "$(HOST: echo ${LAUNCHPAD_TOKEN})"
SNAP: no-architectures
SNAP/all: all
SNAP/no_architectures: no-architectures
SNAP/architectures: architectures
SNAPCRAFT_REMOTE_BUILD_STRATEGY: force-fallback
CREDENTIALS_FILE: "$HOME/.local/share/snapcraft/launchpad-credentials"
CREDENTIALS_FILE/new_credentials: "$HOME/.local/share/snapcraft/launchpad-credentials"
CREDENTIALS_FILE/old_credentials: "$HOME/.local/share/snapcraft/provider/launchpad/credentials"

prepare: |
cd "./snaps/$SNAP"
if [[ -z "$LAUNCHPAD_TOKEN" ]]; then
echo "No credentials set in env LAUNCHPAD_TOKEN"
exit 1
fi
# commit the project
git config --global --add safe.directory "$PWD"
git init
git add snapcraft.yaml
git commit -m "Initial Commit"
# set up launchpad token
mkdir -p "$(dirname "$CREDENTIALS_FILE")"
echo -e "$LAUNCHPAD_TOKEN" >> "$CREDENTIALS_FILE"
restore: |
cd "./snaps/$SNAP"
rm -f ./*.snap ./*.txt
execute: |
cd "./snaps/$SNAP"
snapcraft remote-build --launchpad-accept-public-upload
find . -maxdepth 1 -name "*.snap" | MATCH ".snap"
# confirm the snaps with the expected architectures were built
while read -r expected_snap; do
if [[ ! -e $expected_snap ]]; then
echo "Could not find snap '$expected_snap'"
exit 1
fi
done < "expected-snaps.txt"
# confirm no other snaps were built
expected_number_of_snaps=$(wc -l < "expected-snaps.txt")
actual_number_of_snaps=$(find . -wholename "./*.snap" | wc -l)
if [[ $expected_number_of_snaps -ne $actual_number_of_snaps ]]; then
echo "Expected $expected_number_of_snaps to be built, but $actual_number_of_snaps were built."
exit 1
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test-snap-no-architectures-core22_1.0_amd64.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: test-snap-no-architectures-core22
base: core22
version: "1.0"
summary: Test snap for remote build
description: Test snap for remote build

grade: stable
confinement: strict

parts:
my-part:
plugin: nil
51 changes: 51 additions & 0 deletions tests/spread/core22/remote-build-legacy/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
summary: Test the legacy remote builder for core22
manual: true
kill-timeout: 180m

environment:
LAUNCHPAD_TOKEN: "$(HOST: echo ${LAUNCHPAD_TOKEN})"
SNAP: no-architectures
SNAPCRAFT_REMOTE_BUILD_STRATEGY: force-fallback
CREDENTIALS_FILE: "$HOME/.local/share/snapcraft/launchpad-credentials"
CREDENTIALS_FILE/new_credentials: "$HOME/.local/share/snapcraft/launchpad-credentials"
CREDENTIALS_FILE/old_credentials: "$HOME/.local/share/snapcraft/provider/launchpad/credentials"

prepare: |
cd "./snaps/$SNAP"
if [[ -z "$LAUNCHPAD_TOKEN" ]]; then
echo "No credentials set in env LAUNCHPAD_TOKEN"
exit 1
fi
# set up launchpad token
mkdir -p "$(dirname "$CREDENTIALS_FILE")"
echo -e "$LAUNCHPAD_TOKEN" >> "$CREDENTIALS_FILE"
restore: |
cd "./snaps/$SNAP"
rm -f ./*.snap ./*.txt
execute: |
cd "./snaps/$SNAP"
snapcraft remote-build --launchpad-accept-public-upload
find . -maxdepth 1 -name "*.snap" | MATCH ".snap"
# confirm the snaps with the expected architectures were built
while read -r expected_snap; do
if [[ ! -e $expected_snap ]]; then
echo "Could not find snap '$expected_snap'"
exit 1
fi
done < "expected-snaps.txt"
# confirm no other snaps were built
expected_number_of_snaps=$(wc -l < "expected-snaps.txt")
actual_number_of_snaps=$(find . -wholename "./*.snap" | wc -l)
if [[ $expected_number_of_snaps -ne $actual_number_of_snaps ]]; then
echo "Expected $expected_number_of_snaps to be built, but $actual_number_of_snaps were built."
exit 1
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test-snap-all-core22_1.0_all.snap
16 changes: 16 additions & 0 deletions tests/spread/core22/remote-build/snaps/all/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: test-snap-all-core22
base: core22
version: "1.0"
summary: Test snap for remote build
description: Test snap for remote build

grade: stable
confinement: strict

architectures:
- build-on: [amd64]
build-for: [all]

parts:
my-part:
plugin: nil
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test-snap-architectures-core22_1.0_amd64.snap
test-snap-architectures-core22_1.0_arm64.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: test-snap-architectures-core22
base: core22
version: "1.0"
summary: Test snap for remote build
description: Test snap for remote build

grade: stable
confinement: strict

architectures:
- build-on: [amd64]
build-for: [amd64]
- build-on: [arm64]
build-for: [arm64]

parts:
my-part:
plugin: nil
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test-snap-no-architectures-core22_1.0_amd64.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: test-snap-no-architectures-core22
base: core22
version: "1.0"
summary: Test snap for remote build
description: Test snap for remote build

grade: stable
confinement: strict

parts:
my-part:
plugin: nil
60 changes: 60 additions & 0 deletions tests/spread/core22/remote-build/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
summary: Test the remote builder for core22
manual: true
kill-timeout: 180m

environment:
LAUNCHPAD_TOKEN: "$(HOST: echo ${LAUNCHPAD_TOKEN})"
SNAP: no-architectures
SNAP/all: all
SNAP/no_architectures: no-architectures
SNAP/architectures: architectures
SNAPCRAFT_REMOTE_BUILD_STRATEGY: disable-fallback
CREDENTIALS_FILE: "$HOME/.local/share/snapcraft/launchpad-credentials"
CREDENTIALS_FILE/new_credentials: "$HOME/.local/share/snapcraft/launchpad-credentials"
CREDENTIALS_FILE/old_credentials: "$HOME/.local/share/snapcraft/provider/launchpad/credentials"

prepare: |
cd "./snaps/$SNAP"
if [[ -z "$LAUNCHPAD_TOKEN" ]]; then
echo "No credentials set in env LAUNCHPAD_TOKEN"
exit 1
fi
# commit the project
git config --global --add safe.directory "$PWD"
git init
git add snapcraft.yaml
git commit -m "Initial Commit"
# set up launchpad token
mkdir -p "$(dirname "$CREDENTIALS_FILE")"
echo -e "$LAUNCHPAD_TOKEN" >> "$CREDENTIALS_FILE"
restore: |
cd "./snaps/$SNAP"
rm -f ./*.snap ./*.txt
execute: |
cd "./snaps/$SNAP"
snapcraft remote-build --launchpad-accept-public-upload
find . -maxdepth 1 -name "*.snap" | MATCH ".snap"
# confirm the snaps with the expected architectures were built
while read -r expected_snap; do
if [[ ! -e $expected_snap ]]; then
echo "Could not find snap '$expected_snap'"
exit 1
fi
done < "expected-snaps.txt"
# confirm no other snaps were built
expected_number_of_snaps=$(wc -l < "expected-snaps.txt")
actual_number_of_snaps=$(find . -wholename "./*.snap" | wc -l)
if [[ $expected_number_of_snaps -ne $actual_number_of_snaps ]]; then
echo "Expected $expected_number_of_snaps to be built, but $actual_number_of_snaps were built."
exit 1
fi
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
test-snap-all-core24_1.0_all.snap
2 changes: 1 addition & 1 deletion tests/spread/core24/remote-build/snaps/all/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: test-snap-all-core24
base: core24
version: '1.0'
version: "1.0"
summary: Test snap for remote build
description: Test snap for remote build

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: test-snap-no-platforms-core24
base: core24
version: '0.1'
version: "1.0"
summary: Test snap for remote build
description: Test snap for remote build

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: test-snap-platforms-core24
base: core24
version: '0.1'
version: "1.0"
summary: Test snap for remote build
description: Test snap for remote build

Expand Down
Loading

0 comments on commit d04c205

Please sign in to comment.