diff --git a/.github/workflows/spread-scheduled.yaml b/.github/workflows/spread-scheduled.yaml index cf5258c23d..25484b0aca 100644 --- a/.github/workflows/spread-scheduled.yaml +++ b/.github/workflows/spread-scheduled.yaml @@ -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: | @@ -108,5 +73,8 @@ 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 \ + google:ubuntu-22.04-64:tests/spread/core22/remote-build-legacy \ + google:ubuntu-22.04-64:tests/spread/core22/remote-build \ + google:ubuntu-24.04-64:tests/spread/core24/remote-build \ + google:fedora-39-64:tests/spread/core24/remote-build:no_platforms diff --git a/spread.yaml b/spread.yaml index 21804446a2..9eef183a25 100644 --- a/spread.yaml +++ b/spread.yaml @@ -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: diff --git a/tests/spread/core20/remote-build-legacy/snaps/all/expected-snaps.txt b/tests/spread/core20/remote-build-legacy/snaps/all/expected-snaps.txt new file mode 100644 index 0000000000..ff22b906ff --- /dev/null +++ b/tests/spread/core20/remote-build-legacy/snaps/all/expected-snaps.txt @@ -0,0 +1 @@ +test-snap-all-core20_1.0_all.snap diff --git a/tests/spread/core20/remote-build-legacy/snaps/all/snapcraft.yaml b/tests/spread/core20/remote-build-legacy/snaps/all/snapcraft.yaml new file mode 100644 index 0000000000..f27e56855c --- /dev/null +++ b/tests/spread/core20/remote-build-legacy/snaps/all/snapcraft.yaml @@ -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 diff --git a/tests/spread/core20/remote-build-legacy/snaps/architectures/expected-snaps.txt b/tests/spread/core20/remote-build-legacy/snaps/architectures/expected-snaps.txt new file mode 100644 index 0000000000..51a82ced03 --- /dev/null +++ b/tests/spread/core20/remote-build-legacy/snaps/architectures/expected-snaps.txt @@ -0,0 +1,2 @@ +test-snap-architectures-core20_1.0_amd64.snap +test-snap-architectures-core20_1.0_arm64.snap diff --git a/tests/spread/core20/remote-build-legacy/snaps/architectures/snapcraft.yaml b/tests/spread/core20/remote-build-legacy/snaps/architectures/snapcraft.yaml new file mode 100644 index 0000000000..7fa5d6d774 --- /dev/null +++ b/tests/spread/core20/remote-build-legacy/snaps/architectures/snapcraft.yaml @@ -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 diff --git a/tests/spread/core20/remote-build-legacy/snaps/no-architectures/expected-snaps.txt b/tests/spread/core20/remote-build-legacy/snaps/no-architectures/expected-snaps.txt new file mode 100644 index 0000000000..482e43987c --- /dev/null +++ b/tests/spread/core20/remote-build-legacy/snaps/no-architectures/expected-snaps.txt @@ -0,0 +1 @@ +test-snap-no-architectures-core20_1.0_amd64.snap diff --git a/tests/spread/core20/remote-build-legacy/snaps/no-architectures/snapcraft.yaml b/tests/spread/core20/remote-build-legacy/snaps/no-architectures/snapcraft.yaml new file mode 100644 index 0000000000..d80b302735 --- /dev/null +++ b/tests/spread/core20/remote-build-legacy/snaps/no-architectures/snapcraft.yaml @@ -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 diff --git a/tests/spread/core20/remote-build-legacy/task.yaml b/tests/spread/core20/remote-build-legacy/task.yaml new file mode 100644 index 0000000000..997b28f3af --- /dev/null +++ b/tests/spread/core20/remote-build-legacy/task.yaml @@ -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 diff --git a/tests/spread/core22/remote-build-legacy/snaps/no-architectures/expected-snaps.txt b/tests/spread/core22/remote-build-legacy/snaps/no-architectures/expected-snaps.txt new file mode 100644 index 0000000000..2388cf27aa --- /dev/null +++ b/tests/spread/core22/remote-build-legacy/snaps/no-architectures/expected-snaps.txt @@ -0,0 +1 @@ +test-snap-no-architectures-core22_1.0_amd64.snap diff --git a/tests/spread/core22/remote-build-legacy/snaps/no-architectures/snapcraft.yaml b/tests/spread/core22/remote-build-legacy/snaps/no-architectures/snapcraft.yaml new file mode 100644 index 0000000000..ade4c76d0f --- /dev/null +++ b/tests/spread/core22/remote-build-legacy/snaps/no-architectures/snapcraft.yaml @@ -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 diff --git a/tests/spread/core22/remote-build-legacy/task.yaml b/tests/spread/core22/remote-build-legacy/task.yaml new file mode 100644 index 0000000000..496dfb7deb --- /dev/null +++ b/tests/spread/core22/remote-build-legacy/task.yaml @@ -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 diff --git a/tests/spread/core22/remote-build/snaps/all/expected-snaps.txt b/tests/spread/core22/remote-build/snaps/all/expected-snaps.txt new file mode 100644 index 0000000000..c744da54f0 --- /dev/null +++ b/tests/spread/core22/remote-build/snaps/all/expected-snaps.txt @@ -0,0 +1 @@ +test-snap-all-core22_1.0_all.snap diff --git a/tests/spread/core22/remote-build/snaps/all/snapcraft.yaml b/tests/spread/core22/remote-build/snaps/all/snapcraft.yaml new file mode 100644 index 0000000000..8d6d872be8 --- /dev/null +++ b/tests/spread/core22/remote-build/snaps/all/snapcraft.yaml @@ -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 diff --git a/tests/spread/core22/remote-build/snaps/architectures/expected-snaps.txt b/tests/spread/core22/remote-build/snaps/architectures/expected-snaps.txt new file mode 100644 index 0000000000..fe99de9213 --- /dev/null +++ b/tests/spread/core22/remote-build/snaps/architectures/expected-snaps.txt @@ -0,0 +1,2 @@ +test-snap-architectures-core22_1.0_amd64.snap +test-snap-architectures-core22_1.0_arm64.snap diff --git a/tests/spread/core22/remote-build/snaps/architectures/snapcraft.yaml b/tests/spread/core22/remote-build/snaps/architectures/snapcraft.yaml new file mode 100644 index 0000000000..947152e967 --- /dev/null +++ b/tests/spread/core22/remote-build/snaps/architectures/snapcraft.yaml @@ -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 diff --git a/tests/spread/core22/remote-build/snaps/no-architectures/expected-snaps.txt b/tests/spread/core22/remote-build/snaps/no-architectures/expected-snaps.txt new file mode 100644 index 0000000000..2388cf27aa --- /dev/null +++ b/tests/spread/core22/remote-build/snaps/no-architectures/expected-snaps.txt @@ -0,0 +1 @@ +test-snap-no-architectures-core22_1.0_amd64.snap diff --git a/tests/spread/core22/remote-build/snaps/no-architectures/snapcraft.yaml b/tests/spread/core22/remote-build/snaps/no-architectures/snapcraft.yaml new file mode 100644 index 0000000000..ade4c76d0f --- /dev/null +++ b/tests/spread/core22/remote-build/snaps/no-architectures/snapcraft.yaml @@ -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 diff --git a/tests/spread/core22/remote-build/task.yaml b/tests/spread/core22/remote-build/task.yaml new file mode 100644 index 0000000000..06faeb0703 --- /dev/null +++ b/tests/spread/core22/remote-build/task.yaml @@ -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 diff --git a/tests/spread/core24/remote-build/snaps/all/snapcraft.yaml b/tests/spread/core24/remote-build/snaps/all/snapcraft.yaml index de465af5fc..2ff2511a3e 100644 --- a/tests/spread/core24/remote-build/snaps/all/snapcraft.yaml +++ b/tests/spread/core24/remote-build/snaps/all/snapcraft.yaml @@ -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 diff --git a/tests/spread/core24/remote-build/snaps/no-platforms/snapcraft.yaml b/tests/spread/core24/remote-build/snaps/no-platforms/snapcraft.yaml index 85f435a848..4cc212fa35 100644 --- a/tests/spread/core24/remote-build/snaps/no-platforms/snapcraft.yaml +++ b/tests/spread/core24/remote-build/snaps/no-platforms/snapcraft.yaml @@ -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 diff --git a/tests/spread/core24/remote-build/snaps/platforms/snapcraft.yaml b/tests/spread/core24/remote-build/snaps/platforms/snapcraft.yaml index d88232c8ff..e32f72cb87 100644 --- a/tests/spread/core24/remote-build/snaps/platforms/snapcraft.yaml +++ b/tests/spread/core24/remote-build/snaps/platforms/snapcraft.yaml @@ -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 diff --git a/tests/spread/core24/remote-build/task.yaml b/tests/spread/core24/remote-build/task.yaml index 488b8cb7ca..4ab305f8c4 100644 --- a/tests/spread/core24/remote-build/task.yaml +++ b/tests/spread/core24/remote-build/task.yaml @@ -1,12 +1,20 @@ summary: Test the remote builder for core24 manual: true kill-timeout: 180m +systems: + - fedora-* + - ubuntu-* environment: LAUNCHPAD_TOKEN: "$(HOST: echo ${LAUNCHPAD_TOKEN})" - SNAP/all: all - SNAP/platforms: platforms + SNAP: no-platforms + # launchpad can't parse `platforms` (https://github.com/canonical/snapcraft/issues/4858) + #SNAP/all: all + #SNAP/platforms: platforms SNAP/no_platforms: no-platforms + 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" @@ -19,18 +27,17 @@ prepare: | # commit the project git config --global --add safe.directory "$PWD" git init - git add snap/snapcraft.yaml + git add snapcraft.yaml git commit -m "Initial Commit" # set up launchpad token - mkdir -p ~/.local/share/snapcraft/ - echo -e "$LAUNCHPAD_TOKEN" >> ~/.local/share/snapcraft/launchpad-credentials + mkdir -p "$(dirname "$CREDENTIALS_FILE")" + echo -e "$LAUNCHPAD_TOKEN" >> "$CREDENTIALS_FILE" restore: | cd "./snaps/$SNAP" rm -f ./*.snap ./*.txt - rm -rf snap .git execute: | diff --git a/tests/spread/general/remote-build/architectures-snap.yaml b/tests/spread/general/remote-build/architectures-snap.yaml deleted file mode 100644 index b53dc6897f..0000000000 --- a/tests/spread/general/remote-build/architectures-snap.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: test-snap -version: '0.1' -summary: test -description: test - -grade: devel -confinement: devmode - -base: core22 - -architectures: - - build-on: arm64 - - amd64 - - build-for: s390x - - -parts: - my-part: - plugin: nil diff --git a/tests/spread/general/remote-build/platforms-snap.yaml b/tests/spread/general/remote-build/platforms-snap.yaml deleted file mode 100644 index 5b1ec24334..0000000000 --- a/tests/spread/general/remote-build/platforms-snap.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: test-snap -version: '0.1' -summary: test -description: test - -grade: devel -confinement: devmode - -base: core24 - -platforms: - arm64: - x64: - build-for: [amd64] - build-on: [arm64, amd64, riscv64] - mainframe: - build-on: [s390x] - - -parts: - my-part: - plugin: nil diff --git a/tests/spread/general/remote-build/task.yaml b/tests/spread/general/remote-build/task.yaml deleted file mode 100644 index db01eb2502..0000000000 --- a/tests/spread/general/remote-build/task.yaml +++ /dev/null @@ -1,53 +0,0 @@ -summary: Test the remote builder -manual: true -kill-timeout: 180m -systems: - - fedora-39-64 - - ubuntu-22.04* - -environment: - LAUNCHPAD_TOKEN: "$(HOST: echo ${LAUNCHPAD_TOKEN})" - STRATEGY: "" - STRATEGY/DISABLE_FALLBACK: "disable-fallback" - STRATEGY/FORCE_FALLBACK: "force-fallback" - SNAPCRAFT_FILE: "" - SNAPCRAFT_FILE/architectures: "architectures-snap.yaml" - SNAPCRAFT_FILE/platforms: "platforms-snap.yaml" - -prepare: | - if [[ -z "$LAUNCHPAD_TOKEN" ]]; then - echo "No credentials set in env LAUNCHPAD_TOKEN" - exit 1 - fi - - if [ -z "${SNAPCRAFT_FILE}" ]; then - snapcraft init - else - mkdir snap - cp "${SNAPCRAFT_FILE}" snap/snapcraft.yaml - fi - - # Commit the project - git config --global --add safe.directory "$PWD" - git init - git add snap/snapcraft.yaml - git commit -m "Initial Commit" - - # Set up launchpad token - if [[ $STRATEGY == "disable-fallback" ]]; then - mkdir -p ~/.local/share/snapcraft/ - echo -e "$LAUNCHPAD_TOKEN" >> ~/.local/share/snapcraft/launchpad-credentials - else - mkdir -p ~/.local/share/snapcraft/provider/launchpad/ - echo -e "$LAUNCHPAD_TOKEN" >> ~/.local/share/snapcraft/provider/launchpad/credentials - fi - -restore: | - rm -f ./*.snap ./*.txt - - rm -rf snap .git - -execute: | - export SNAPCRAFT_REMOTE_BUILD_STRATEGY="$STRATEGY" - - snapcraft remote-build --launchpad-accept-public-upload