diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml new file mode 100644 index 0000000..c5a216c --- /dev/null +++ b/.github/workflows/integration-test.yaml @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Canonical Ltd. +name: Integration Tests +on: + push: + branches: ["main"] + pull_request: +jobs: + toy-test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Run toy integration test + uses: ./ + with: + garden-system: ubuntu-cloud-24.04 + spread-subdir: tests/toy diff --git a/.gitignore b/.gitignore index 5e87306..a08316f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Canonical Ltd. +.image-garden/* +!.image-garden/README.md diff --git a/action.yaml b/action.yaml index 5c9d305..c5826dc 100644 --- a/action.yaml +++ b/action.yaml @@ -84,7 +84,7 @@ runs: path: | ${{ inputs.spread-subdir }}/.image-garden !${{ inputs.spread-subdir }}/.image-garden/*.log - key: image-garden-img-${{ inputs.garden-system }}-${{ hashFiles('.image-garden.mk') }} + key: image-garden-img-${{ inputs.garden-system }}-${{ hashFiles(format('{0}/.image-garden.mk', inputs.spread-subdir)) }} - name: Restore mtime of .image-garden.mk if: hashFiles('.image-garden.mk') != '' shell: bash diff --git a/tests/toy/.image-garden.mk b/tests/toy/.image-garden.mk new file mode 100644 index 0000000..5e87306 --- /dev/null +++ b/tests/toy/.image-garden.mk @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Canonical Ltd. diff --git a/tests/toy/.image-garden/README.md b/tests/toy/.image-garden/README.md new file mode 100644 index 0000000..e60294f --- /dev/null +++ b/tests/toy/.image-garden/README.md @@ -0,0 +1,13 @@ + + +# Image Garden State Directory + +This directory is used by `image-garden` to store large temporary files. +It should be ignored in `.gitignore` apart from this `README.md` file +itself. + +Consult documentation of [spread](https://github.com/canonical/spread) and +[image-garden](https://gitlab.com/zygoon/image-garden). diff --git a/tests/toy/spread.yaml b/tests/toy/spread.yaml new file mode 100644 index 0000000..d552ab8 --- /dev/null +++ b/tests/toy/spread.yaml @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Canonical Ltd. +project: toy +path: /root/toy +exclude: + - .image-garden/ + - .git +backends: + garden: + type: adhoc + allocate: | + if [ -n "${SPREAD_HOST_PATH-}" ]; then + PATH="$SPREAD_HOST_PATH" + fi + exec image-garden allocate "$SPREAD_SYSTEM"."$(uname -m)" + discard: | + if [ -n "${SPREAD_HOST_PATH-}" ]; then + PATH="$SPREAD_HOST_PATH" + fi + exec image-garden discard "$SPREAD_SYSTEM_ADDRESS" + systems: + - ubuntu-cloud-24.04: + username: root + password: root +suites: + tests/: + summary: Toy integration tests diff --git a/tests/toy/tests/success/task.yaml b/tests/toy/tests/success/task.yaml new file mode 100644 index 0000000..9ec6d82 --- /dev/null +++ b/tests/toy/tests/success/task.yaml @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Canonical Ltd. +summary: Simple success test that prints hello world +execute: | + echo "hello world" + echo "Integration test successful!"