From 7919a62b200c1ae8727111815b5c6bfed9d14191 Mon Sep 17 00:00:00 2001 From: Sinan KARAKAYA Date: Wed, 25 Mar 2026 11:19:15 +0100 Subject: [PATCH 1/8] workflows: renamed legacy incident yml file extension Rename integration_tests.yaml.yml to integration_tets.yml Signed-off-by: Sinan KARAKAYA --- .../{integration_tests.yaml.yml => integration_tests.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{integration_tests.yaml.yml => integration_tests.yml} (100%) diff --git a/.github/workflows/integration_tests.yaml.yml b/.github/workflows/integration_tests.yml similarity index 100% rename from .github/workflows/integration_tests.yaml.yml rename to .github/workflows/integration_tests.yml From 52d735f52c26ce7fc1c95ca9cd7cbae0342e0e81 Mon Sep 17 00:00:00 2001 From: Sinan KARAKAYA Date: Wed, 25 Mar 2026 14:08:58 +0100 Subject: [PATCH 2/8] workflows: added snap-store integration workflow and update DUT installer Add a manual workflow to run snap store channel tests via testflinger. Update DUT install logic to support local snap and store-channel installs. Signed-off-by: Sinan KARAKAYA --- .../test_snap_device_script.sh | 17 +++- .../snap_store_integration_tests.yml | 92 +++++++++++++++++++ 2 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/snap_store_integration_tests.yml diff --git a/.github/testflinger-assets/test_snap_device_script.sh b/.github/testflinger-assets/test_snap_device_script.sh index 82bea702..db2f7d7b 100755 --- a/.github/testflinger-assets/test_snap_device_script.sh +++ b/.github/testflinger-assets/test_snap_device_script.sh @@ -16,12 +16,23 @@ while sudo snap debug state /var/lib/snapd/state.json | grep -qE 'Doing|Undoing| done echo " --- Disabling auto-refresh for 24 hours" sudo snap refresh --hold=24h -echo " --- Installing fpgad.snap" - while sudo snap debug state /var/lib/snapd/state.json | grep -qE 'Doing|Undoing|Waiting'; do +echo " --- Installing fpgad" +while sudo snap debug state /var/lib/snapd/state.json | grep -qE 'Doing|Undoing|Waiting'; do echo " --- snapd internal tasks still running... waiting..." sleep 10 done -sudo snap install ./fpgad.snap --dangerous + +if [[ -f ./fpgad.snap ]]; then + echo " --- Found local snap attachment, installing ./fpgad.snap --dangerous" + sudo snap install ./fpgad.snap --dangerous +else + SNAP_CHANNEL="stable" + if [[ -f ./snap_channel.txt ]]; then + SNAP_CHANNEL="$(head -n1 ./snap_channel.txt | xargs)" + fi + echo " --- No local snap attachment found, installing from store channel: ${SNAP_CHANNEL}" + sudo snap install fpgad --channel="${SNAP_CHANNEL}" +fi echo " --- Installing provider snap(s)" echo "INFO: Done preparing device" diff --git a/.github/workflows/snap_store_integration_tests.yml b/.github/workflows/snap_store_integration_tests.yml new file mode 100644 index 00000000..bd0559d1 --- /dev/null +++ b/.github/workflows/snap_store_integration_tests.yml @@ -0,0 +1,92 @@ +name: Run snap-store integration tests on a DUT via testflinger +on: + workflow_dispatch: + inputs: + snap_channel: + description: "Snap Store channel/track (examples: beta, edge, latest/stable)" + required: true + default: beta + type: string + cid: + description: "Device identifier suffix as seen in C3 (example: c36973)" + required: true + default: c36973 + type: string +jobs: + snap-store-integration-tests: + name: Install and Test Store Snap on DUT + runs-on: [self-hosted, self-hosted-linux-amd64-noble-private-endpoint-medium] + timeout-minutes: 3600 + steps: + - name: checkout + uses: actions/checkout@v6 + - name: Install dependencies + shell: bash + run: | + echo "::group::install dependencies" + sudo snap install yq + echo "::endgroup::" + - name: Prepare Testflinger Job + id: prepare-tf-job + shell: bash + run: | + echo "::group::prepare selectors" + printf '%s\n' '${{ inputs.snap_channel }}' > snap_channel.txt + export TF_JOB_QUEUE="${{ inputs.cid }}" + echo "Using snap channel: $(cat snap_channel.txt)" + echo "Using testflinger queue: ${TF_JOB_QUEUE}" + echo "::endgroup::" + echo "::group::Create test_data tarball" + tar -czvf test_data.gz -C daemon/tests/test_data/ . + echo "::endgroup::" + echo "::group::creating job.yaml" + yq ' + .job_queue = env(TF_JOB_QUEUE) | + .test_data.attachments = [ + { "agent": "device_script.sh", "local": "'"$(pwd)"'/.github/testflinger-assets/test_snap_device_script.sh" }, + { "agent": "snap_channel.txt", "local": "'"$(pwd)"'/snap_channel.txt" }, + { "agent": "test_data.gz", "local": "'"$(pwd)"'/test_data.gz" }, + { "agent": "snap_tests.py", "local": "'"$(pwd)"'/tests/snap_tests.py" } + ] + ' .github/testflinger-assets/testflinger_job.yaml | tee job.yaml + echo "::endgroup::" + echo "test_path=job.yaml" >> $GITHUB_OUTPUT + - name: Submit TF job + id: submit + uses: canonical/testflinger/.github/actions/submit@rev263 + continue-on-error: true + with: + poll: true + job-path: ${{ steps.prepare-tf-job.outputs.test_path }} + - name: Fetch and Display Artifacts + shell: bash + run: | + echo "::group::retrieving snap store test artifacts" + testflinger artifacts ${{steps.submit.outputs.id }} + tar -xvzf artifacts.tgz + echo "::endgroup::" + for f in artifacts/* ; do + echo "::group::$f" + cat "$f" + echo "::endgroup::" + done + - name: Upload artifacts + uses: actions/upload-artifact@v6 + with: + name: snap-store-testing-artifacts + path: artifacts/* + - name: Report test status + shell: bash + run: |- + if [ "${{ steps.submit.outcome }}" != "success" ]; then + echo "::error::test job didn't complete successfully" + exit 1 + fi + if [[ ! -f artifacts/snap_test.log ]]; then + echo "::error::snap_test.log not found, did the tests fail to start?" + exit 1 + fi + if grep -q "FAILED (" artifacts/snap_test.log; then + echo "::error::found failure phrase in snap_test.log" + exit 1 + fi From b2149db02f9421d58515aa01e3abe572e43f4fad Mon Sep 17 00:00:00 2001 From: Sinan KARAKAYA Date: Wed, 25 Mar 2026 16:14:27 +0100 Subject: [PATCH 3/8] workflows: unified snap jobs and moved them to their own workflows Created snap_integration_tests.yml to unify the snap jobs, making integration_tests.yml lighter The new snap integration tests can handle both local snaps and snapstore snaps Signed-off-by: Sinan KARAKAYA --- .github/workflows/integration_tests.yml | 106 ------------ .github/workflows/snap_integration_tests.yml | 163 ++++++++++++++++++ .../snap_store_integration_tests.yml | 92 ---------- 3 files changed, 163 insertions(+), 198 deletions(-) create mode 100644 .github/workflows/snap_integration_tests.yml delete mode 100644 .github/workflows/snap_store_integration_tests.yml diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 26f3d21b..b599b599 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -1,6 +1,5 @@ name: Run integration tests on a DUT via testflinger on: - workflow_dispatch: pull_request: jobs: binary-integration-tests: @@ -77,108 +76,3 @@ jobs: echo "::error::found failure phrase in coverage_test.log" exit 1 fi - snap-build: - name: Check Snap Builds - runs-on: [self-hosted, linux, noble, ARM64] - outputs: - atifact_id: ${{ steps.upload-snap.outputs.artifact-id }} - steps: - - uses: actions/checkout@v6 - - uses: canonical/action-build@v1.3.0 - id: snapcraft - - uses: actions/upload-artifact@v7 - id: upload-snap - with: - name: snap-fpgad-${{ github.event.pull_request != null && github.event.pull_request.head.sha || 'workflow-dispatch' }} - path: ${{ steps.snapcraft.outputs.snap }} - snap-integration-tests: - name: Install and Test the Snap Package on DUT - runs-on: [self-hosted, self-hosted-linux-amd64-noble-private-endpoint-medium] - if: ${{ !github.event.pull_request.draft }} - needs: ['snap-build'] - timeout-minutes: 3600 - steps: - - name: checkout - uses: actions/checkout@v6 - - name: Install dependencies - shell: bash - run: | - echo "::group::install dependencies" - sudo snap install yq - echo "::endgroup::" - - name: Download built snap - id: download-snap - uses: actions/download-artifact@v8 - with: - artifact-ids: ${{ needs.build.outputs.atifact_id }} - path: ./ - - name: Prepare Testflinger Job - id: prepare-tf-job - run: | - echo "::group::Preparing fpgad.snap" - SRC=$(find "${{ steps.download-snap.outputs.download-path }}" -maxdepth 1 -name "*.snap" | head -n 1) - DEST="$(pwd)/fpgad.snap" - # Check that the source file exists - if [[ -z "$SRC" || ! -f "$SRC" ]]; then - echo "::error::Snap file not found at: $SRC" - exit 1 - fi - # Move file - mv "$SRC" "$DEST" - echo "Snap moved successfully" - echo "::endgroup::" - - echo "::group::Create test_data tarball" - tar -czvf test_data.gz -C daemon/tests/test_data/ . - echo "::endgroup::" - - echo "::group::creating job.yaml" - yq '.test_data.attachments = [ - { "agent": "device_script.sh", "local": "'"$(pwd)"'/.github/testflinger-assets/test_snap_device_script.sh" }, - { "agent": "fpgad.snap", "local": "'"$(pwd)"'/fpgad.snap" }, - { "agent": "test_data.gz", "local": "'"$(pwd)"'/test_data.gz" }, - { "agent": "snap_tests.py", "local": "'"$(pwd)"'/tests/snap_tests.py" } - ]' .github/testflinger-assets/testflinger_job.yaml | tee job.yaml - echo "::endgroup::" - - echo "test_path=job.yaml" >> $GITHUB_OUTPUT - - name: Submit TF job - id: submit - uses: canonical/testflinger/.github/actions/submit@rev263 - continue-on-error: true - with: - poll: true - job-path: ${{ steps.prepare-tf-job.outputs.test_path }} - - name: Fetch and Display Artifacts - shell: bash - run: | - echo "::group::retrieving snap test artifacts" - testflinger artifacts ${{steps.submit.outputs.id }} - tar -xvzf artifacts.tgz - echo "::endgroup::" - - for f in artifacts/* ; do - echo "::group::$f" - cat "$f" - echo "::endgroup::" - done - - name: Upload artifacts - uses: actions/upload-artifact@v7 - with: - name: snap-testing-artifacts - path: artifacts/* - - name: Report test status - shell: bash - run: |- - if [ "${{ steps.submit.outcome }}" != "success" ]; then - echo "::error::test job didn't complete successfully" - exit 1 - fi - if [[ ! -f artifacts/snap_test.log ]]; then - echo "::error::snap_test.log not found, did the tests fail to start?" - exit 1 - fi - if grep -q "FAILED (" artifacts/snap_test.log; then - echo "::error::found failure phrase in snap_test.log" - exit 1 - fi diff --git a/.github/workflows/snap_integration_tests.yml b/.github/workflows/snap_integration_tests.yml new file mode 100644 index 00000000..c922152e --- /dev/null +++ b/.github/workflows/snap_integration_tests.yml @@ -0,0 +1,163 @@ +name: Run snap integration tests on a DUT via testflinger +on: + workflow_dispatch: + inputs: + snap_test_source: + description: "Snap source mode: artifact uses CI-built snap, store installs from Snap Store" + required: true + default: store + type: choice + options: + - artifact + - store + snap_channel: + description: "Snap Store channel/track when source=store (examples: beta, edge, latest/stable)" + required: true + default: beta + type: string + tf_queue: + description: "Device identifier suffix as seen in C3 (example: xilinx-kv260-c36973)" + required: true + default: xilinx-kv260-c36973 + type: string + pull_request: +jobs: + snap-build: + name: Check Snap Builds + runs-on: [self-hosted, linux, noble, ARM64] + outputs: + artifact_id: ${{ steps.upload-snap.outputs.artifact-id }} + steps: + - uses: actions/checkout@v6 + - uses: canonical/action-build@v1.3.0 + id: snapcraft + if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.snap_test_source == 'artifact') }} + - uses: actions/upload-artifact@v6 + id: upload-snap + if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.snap_test_source == 'artifact') }} + with: + name: snap-fpgad-${{ github.event.pull_request != null && github.event.pull_request.head.sha || 'workflow-dispatch' }} + path: ${{ steps.snapcraft.outputs.snap }} + snap-integration-tests: + name: Install and Test the Snap Package on DUT + runs-on: [self-hosted, self-hosted-linux-amd64-noble-private-endpoint-medium] + if: ${{ github.event_name == 'workflow_dispatch' || !github.event.pull_request.draft }} + needs: ['snap-build'] + timeout-minutes: 3600 + steps: + - name: checkout + uses: actions/checkout@v6 + - name: Install dependencies + shell: bash + run: | + echo "::group::install dependencies" + sudo snap install yq + echo "::endgroup::" + - name: Download built snap + id: download-snap + uses: actions/download-artifact@v7 + if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.snap_test_source == 'artifact') }} + with: + artifact-ids: ${{ needs['snap-build'].outputs.artifact_id }} + path: ./ + - name: Prepare Testflinger Job + id: prepare-tf-job + shell: bash + run: | + SNAP_TEST_SOURCE="${{ github.event_name == 'pull_request' && 'artifact' || inputs.snap_test_source }}" + SNAP_CHANNEL="${{ inputs.snap_channel || 'beta' }}" + + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + export TF_JOB_QUEUE="xilinx-kv260-c36973" + else + export TF_JOB_QUEUE="${{ inputs.tf_queue }}" + fi + + if [[ "${SNAP_TEST_SOURCE}" == "artifact" ]]; then + echo "::group::Preparing fpgad.snap" + SRC=$(find "${{ steps.download-snap.outputs.download-path }}" -maxdepth 1 -name "*.snap" | head -n 1) + DEST="$(pwd)/fpgad.snap" + if [[ -z "$SRC" || ! -f "$SRC" ]]; then + echo "::error::Snap file not found at: $SRC" + exit 1 + fi + mv "$SRC" "$DEST" + echo "Snap moved successfully" + echo "::endgroup::" + else + echo "::group::Preparing store channel selector" + printf '%s\n' "${SNAP_CHANNEL}" > snap_channel.txt + echo "Using store channel: $(cat snap_channel.txt)" + echo "::endgroup::" + fi + + echo "::group::Create test_data tarball" + tar -czvf test_data.gz -C daemon/tests/test_data/ . + echo "::endgroup::" + + echo "::group::creating job.yaml" + ROOT_DIR="$(pwd)" + + yq ' + .job_queue = env(TF_JOB_QUEUE) | + .test_data.attachments = [ + { "agent": "device_script.sh", "local": "'"${ROOT_DIR}"'/.github/testflinger-assets/test_snap_device_script.sh" }, + { "agent": "test_data.gz", "local": "'"${ROOT_DIR}"'/test_data.gz" }, + { "agent": "snap_tests.py", "local": "'"${ROOT_DIR}"'/tests/snap_tests.py" } + ] + ' .github/testflinger-assets/testflinger_job.yaml > job.yaml + + # Append source-specific attachment + if [[ "${SNAP_TEST_SOURCE}" == "artifact" ]]; then + yq -i '.test_data.attachments += [ + { "agent": "fpgad.snap", "local": "'"${ROOT_DIR}"'/fpgad.snap" } + ]' job.yaml + else + yq -i '.test_data.attachments += [ + { "agent": "snap_channel.txt", "local": "'"${ROOT_DIR}"'/snap_channel.txt" } + ]' job.yaml + fi + + cat job.yaml + echo "::endgroup::" + + echo "test_path=job.yaml" >> $GITHUB_OUTPUT + - name: Submit TF job + id: submit + uses: canonical/testflinger/.github/actions/submit@rev263 + continue-on-error: true + with: + poll: true + job-path: ${{ steps.prepare-tf-job.outputs.test_path }} + - name: Fetch and Display Artifacts + shell: bash + run: | + echo "::group::retrieving snap test artifacts" + testflinger artifacts ${{steps.submit.outputs.id }} + tar -xvzf artifacts.tgz + echo "::endgroup::" + for f in artifacts/* ; do + echo "::group::$f" + cat "$f" + echo "::endgroup::" + done + - name: Upload artifacts + uses: actions/upload-artifact@v6 + with: + name: snap-testing-artifacts + path: artifacts/* + - name: Report test status + shell: bash + run: |- + if [ "${{ steps.submit.outcome }}" != "success" ]; then + echo "::error::test job didn't complete successfully" + exit 1 + fi + if [[ ! -f artifacts/snap_test.log ]]; then + echo "::error::snap_test.log not found, did the tests fail to start?" + exit 1 + fi + if grep -q "FAILED (" artifacts/snap_test.log; then + echo "::error::found failure phrase in snap_test.log" + exit 1 + fi diff --git a/.github/workflows/snap_store_integration_tests.yml b/.github/workflows/snap_store_integration_tests.yml deleted file mode 100644 index bd0559d1..00000000 --- a/.github/workflows/snap_store_integration_tests.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: Run snap-store integration tests on a DUT via testflinger -on: - workflow_dispatch: - inputs: - snap_channel: - description: "Snap Store channel/track (examples: beta, edge, latest/stable)" - required: true - default: beta - type: string - cid: - description: "Device identifier suffix as seen in C3 (example: c36973)" - required: true - default: c36973 - type: string -jobs: - snap-store-integration-tests: - name: Install and Test Store Snap on DUT - runs-on: [self-hosted, self-hosted-linux-amd64-noble-private-endpoint-medium] - timeout-minutes: 3600 - steps: - - name: checkout - uses: actions/checkout@v6 - - name: Install dependencies - shell: bash - run: | - echo "::group::install dependencies" - sudo snap install yq - echo "::endgroup::" - - name: Prepare Testflinger Job - id: prepare-tf-job - shell: bash - run: | - echo "::group::prepare selectors" - printf '%s\n' '${{ inputs.snap_channel }}' > snap_channel.txt - export TF_JOB_QUEUE="${{ inputs.cid }}" - echo "Using snap channel: $(cat snap_channel.txt)" - echo "Using testflinger queue: ${TF_JOB_QUEUE}" - echo "::endgroup::" - echo "::group::Create test_data tarball" - tar -czvf test_data.gz -C daemon/tests/test_data/ . - echo "::endgroup::" - echo "::group::creating job.yaml" - yq ' - .job_queue = env(TF_JOB_QUEUE) | - .test_data.attachments = [ - { "agent": "device_script.sh", "local": "'"$(pwd)"'/.github/testflinger-assets/test_snap_device_script.sh" }, - { "agent": "snap_channel.txt", "local": "'"$(pwd)"'/snap_channel.txt" }, - { "agent": "test_data.gz", "local": "'"$(pwd)"'/test_data.gz" }, - { "agent": "snap_tests.py", "local": "'"$(pwd)"'/tests/snap_tests.py" } - ] - ' .github/testflinger-assets/testflinger_job.yaml | tee job.yaml - echo "::endgroup::" - echo "test_path=job.yaml" >> $GITHUB_OUTPUT - - name: Submit TF job - id: submit - uses: canonical/testflinger/.github/actions/submit@rev263 - continue-on-error: true - with: - poll: true - job-path: ${{ steps.prepare-tf-job.outputs.test_path }} - - name: Fetch and Display Artifacts - shell: bash - run: | - echo "::group::retrieving snap store test artifacts" - testflinger artifacts ${{steps.submit.outputs.id }} - tar -xvzf artifacts.tgz - echo "::endgroup::" - for f in artifacts/* ; do - echo "::group::$f" - cat "$f" - echo "::endgroup::" - done - - name: Upload artifacts - uses: actions/upload-artifact@v6 - with: - name: snap-store-testing-artifacts - path: artifacts/* - - name: Report test status - shell: bash - run: |- - if [ "${{ steps.submit.outcome }}" != "success" ]; then - echo "::error::test job didn't complete successfully" - exit 1 - fi - if [[ ! -f artifacts/snap_test.log ]]; then - echo "::error::snap_test.log not found, did the tests fail to start?" - exit 1 - fi - if grep -q "FAILED (" artifacts/snap_test.log; then - echo "::error::found failure phrase in snap_test.log" - exit 1 - fi From ca3044ac775de46cbd791972017b96b8c4d8ce3a Mon Sep 17 00:00:00 2001 From: Sinan KARAKAYA Date: Thu, 26 Mar 2026 14:42:23 +0100 Subject: [PATCH 4/8] workflows: merged snap_test_source and snap_channel In snap_integration_tests.yml, merged snap_test_source and snap_channel inputs to support both snap store channels, and local builds. Signed-off-by: Sinan KARAKAYA --- .github/workflows/snap_integration_tests.yml | 25 +++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/.github/workflows/snap_integration_tests.yml b/.github/workflows/snap_integration_tests.yml index c922152e..27d51d70 100644 --- a/.github/workflows/snap_integration_tests.yml +++ b/.github/workflows/snap_integration_tests.yml @@ -3,17 +3,9 @@ on: workflow_dispatch: inputs: snap_test_source: - description: "Snap source mode: artifact uses CI-built snap, store installs from Snap Store" + description: "Snap source channel when source=store (examples: local, beta, edge, stable). If source=local, will use a locally built snap." required: true - default: store - type: choice - options: - - artifact - - store - snap_channel: - description: "Snap Store channel/track when source=store (examples: beta, edge, latest/stable)" - required: true - default: beta + default: local type: string tf_queue: description: "Device identifier suffix as seen in C3 (example: xilinx-kv260-c36973)" @@ -31,10 +23,10 @@ jobs: - uses: actions/checkout@v6 - uses: canonical/action-build@v1.3.0 id: snapcraft - if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.snap_test_source == 'artifact') }} + if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.snap_test_source == 'local') }} - uses: actions/upload-artifact@v6 id: upload-snap - if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.snap_test_source == 'artifact') }} + if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.snap_test_source == 'local') }} with: name: snap-fpgad-${{ github.event.pull_request != null && github.event.pull_request.head.sha || 'workflow-dispatch' }} path: ${{ steps.snapcraft.outputs.snap }} @@ -56,7 +48,7 @@ jobs: - name: Download built snap id: download-snap uses: actions/download-artifact@v7 - if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.snap_test_source == 'artifact') }} + if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.snap_test_source == 'local') }} with: artifact-ids: ${{ needs['snap-build'].outputs.artifact_id }} path: ./ @@ -64,8 +56,7 @@ jobs: id: prepare-tf-job shell: bash run: | - SNAP_TEST_SOURCE="${{ github.event_name == 'pull_request' && 'artifact' || inputs.snap_test_source }}" - SNAP_CHANNEL="${{ inputs.snap_channel || 'beta' }}" + SNAP_TEST_SOURCE="${{ inputs.snap_test_source }}" if [[ "${{ github.event_name }}" == "pull_request" ]]; then export TF_JOB_QUEUE="xilinx-kv260-c36973" @@ -73,7 +64,7 @@ jobs: export TF_JOB_QUEUE="${{ inputs.tf_queue }}" fi - if [[ "${SNAP_TEST_SOURCE}" == "artifact" ]]; then + if [[ "${SNAP_TEST_SOURCE}" == "local" ]]; then echo "::group::Preparing fpgad.snap" SRC=$(find "${{ steps.download-snap.outputs.download-path }}" -maxdepth 1 -name "*.snap" | head -n 1) DEST="$(pwd)/fpgad.snap" @@ -86,7 +77,7 @@ jobs: echo "::endgroup::" else echo "::group::Preparing store channel selector" - printf '%s\n' "${SNAP_CHANNEL}" > snap_channel.txt + printf '%s\n' "${SNAP_TEST_SOURCE}" > snap_channel.txt echo "Using store channel: $(cat snap_channel.txt)" echo "::endgroup::" fi From e7720d5bcbb8b1aee06aa4b7228869a47d5d72c2 Mon Sep 17 00:00:00 2001 From: Sinan KARAKAYA Date: Thu, 26 Mar 2026 14:55:44 +0100 Subject: [PATCH 5/8] workflows: moved ROOT_DIR to env for simpler path construction Moved ROOT_DIR to env to remove the need for creating a shell variable. Made path construction use strenv inside yq Signed-off-by: Sinan KARAKAYA --- .github/workflows/snap_integration_tests.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/snap_integration_tests.yml b/.github/workflows/snap_integration_tests.yml index 27d51d70..76bcc0ec 100644 --- a/.github/workflows/snap_integration_tests.yml +++ b/.github/workflows/snap_integration_tests.yml @@ -54,6 +54,8 @@ jobs: path: ./ - name: Prepare Testflinger Job id: prepare-tf-job + env: + ROOT_DIR: ${{ github.workspace }} shell: bash run: | SNAP_TEST_SOURCE="${{ inputs.snap_test_source }}" @@ -67,7 +69,7 @@ jobs: if [[ "${SNAP_TEST_SOURCE}" == "local" ]]; then echo "::group::Preparing fpgad.snap" SRC=$(find "${{ steps.download-snap.outputs.download-path }}" -maxdepth 1 -name "*.snap" | head -n 1) - DEST="$(pwd)/fpgad.snap" + DEST="${ROOT_DIR}/fpgad.snap" if [[ -z "$SRC" || ! -f "$SRC" ]]; then echo "::error::Snap file not found at: $SRC" exit 1 @@ -87,25 +89,23 @@ jobs: echo "::endgroup::" echo "::group::creating job.yaml" - ROOT_DIR="$(pwd)" - yq ' .job_queue = env(TF_JOB_QUEUE) | .test_data.attachments = [ - { "agent": "device_script.sh", "local": "'"${ROOT_DIR}"'/.github/testflinger-assets/test_snap_device_script.sh" }, - { "agent": "test_data.gz", "local": "'"${ROOT_DIR}"'/test_data.gz" }, - { "agent": "snap_tests.py", "local": "'"${ROOT_DIR}"'/tests/snap_tests.py" } + { "agent": "device_script.sh", "local": strenv(ROOT_DIR) + "/.github/testflinger-assets/test_snap_device_script.sh" }, + { "agent": "test_data.gz", "local": strenv(ROOT_DIR) + "/test_data.gz" }, + { "agent": "snap_tests.py", "local": strenv(ROOT_DIR) + "/tests/snap_tests.py" } ] ' .github/testflinger-assets/testflinger_job.yaml > job.yaml # Append source-specific attachment if [[ "${SNAP_TEST_SOURCE}" == "artifact" ]]; then yq -i '.test_data.attachments += [ - { "agent": "fpgad.snap", "local": "'"${ROOT_DIR}"'/fpgad.snap" } + { "agent": "fpgad.snap", "local": strenv(ROOT_DIR) + "/fpgad.snap" } ]' job.yaml else yq -i '.test_data.attachments += [ - { "agent": "snap_channel.txt", "local": "'"${ROOT_DIR}"'/snap_channel.txt" } + { "agent": "snap_channel.txt", "local": strenv(ROOT_DIR) + "/snap_channel.txt" } ]' job.yaml fi From 76caf16e7899ca1eef559487bbef04d77753247e Mon Sep 17 00:00:00 2001 From: Sinan KARAKAYA Date: Thu, 26 Mar 2026 15:12:50 +0100 Subject: [PATCH 6/8] workflows: replaced snap_channel.txt by environment variables Replaced snap_channel.txt by SNAP_TEST_SOURCE environment variable. SNAP_TEST_SOURCE is initialized during the CI, and set to the value of the workflow input. Refactored testflinger_job.yaml to execute and source SNAP_TEST_SOURCE if env_setup.sh is present. Refactored test_snap_device_script.sh to use environment variables instead of text input. Signed-off-by: Sinan KARAKAYA --- .../test_snap_device_script.sh | 24 ++++++++++++------- .../testflinger-assets/testflinger_job.yaml | 2 +- .github/workflows/snap_integration_tests.yml | 24 ++++++++----------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/.github/testflinger-assets/test_snap_device_script.sh b/.github/testflinger-assets/test_snap_device_script.sh index db2f7d7b..d0335a6b 100755 --- a/.github/testflinger-assets/test_snap_device_script.sh +++ b/.github/testflinger-assets/test_snap_device_script.sh @@ -1,6 +1,14 @@ #!/usr/bin/env bash set -euxo pipefail +if [[ -f ./env_setup.sh ]]; then + # shellcheck disable=SC1091 + . ./env_setup.sh +fi + +SNAP_TEST_SOURCE="${SNAP_TEST_SOURCE:-local}" +SNAP_CHANNEL="${SNAP_CHANNEL:-${SNAP_TEST_SOURCE}}" + echo "INFO: Preparing device" echo " --- Updating with apt" sudo env DEBIAN_FRONTEND=noninteractive apt update && sudo env DEBIAN_FRONTEND=noninteractive apt install build-essential -y @@ -22,16 +30,16 @@ while sudo snap debug state /var/lib/snapd/state.json | grep -qE 'Doing|Undoing| sleep 10 done -if [[ -f ./fpgad.snap ]]; then - echo " --- Found local snap attachment, installing ./fpgad.snap --dangerous" +if [[ "${SNAP_TEST_SOURCE}" == "local" ]]; then + if [[ ! -f ./fpgad.snap ]]; then + echo "ERROR: SNAP_TEST_SOURCE=local but ./fpgad.snap is not present" + exit 1 + fi + echo " --- SNAP_TEST_SOURCE=local, installing ./fpgad.snap --dangerous" sudo snap install ./fpgad.snap --dangerous else - SNAP_CHANNEL="stable" - if [[ -f ./snap_channel.txt ]]; then - SNAP_CHANNEL="$(head -n1 ./snap_channel.txt | xargs)" - fi - echo " --- No local snap attachment found, installing from store channel: ${SNAP_CHANNEL}" - sudo snap install fpgad --channel="${SNAP_CHANNEL}" + echo " --- SNAP_TEST_SOURCE=${SNAP_TEST_SOURCE}, installing from store channel: ${SNAP_TEST_SOURCE}" + sudo snap install fpgad --channel="${SNAP_TEST_SOURCE}" fi echo " --- Installing provider snap(s)" echo "INFO: Done preparing device" diff --git a/.github/testflinger-assets/testflinger_job.yaml b/.github/testflinger-assets/testflinger_job.yaml index e52b250b..1e17c329 100644 --- a/.github/testflinger-assets/testflinger_job.yaml +++ b/.github/testflinger-assets/testflinger_job.yaml @@ -51,7 +51,7 @@ test_data: # Run the test script, but always retrieve artifacts even if it fails set +e - _run '/home/ubuntu/device_script.sh' + _run 'if [ -f /home/ubuntu/env_setup.sh ]; then . /home/ubuntu/env_setup.sh; fi; /home/ubuntu/device_script.sh' TEST_SCRIPT_EXIT=$? set -e diff --git a/.github/workflows/snap_integration_tests.yml b/.github/workflows/snap_integration_tests.yml index 76bcc0ec..bbecd0b6 100644 --- a/.github/workflows/snap_integration_tests.yml +++ b/.github/workflows/snap_integration_tests.yml @@ -56,15 +56,15 @@ jobs: id: prepare-tf-job env: ROOT_DIR: ${{ github.workspace }} + SNAP_TEST_SOURCE: ${{ inputs.snap_test_source || 'local' }} + TF_JOB_QUEUE: ${{ inputs.tf_queue || 'xilinx-kv260-c36973' }} shell: bash run: | - SNAP_TEST_SOURCE="${{ inputs.snap_test_source }}" - - if [[ "${{ github.event_name }}" == "pull_request" ]]; then - export TF_JOB_QUEUE="xilinx-kv260-c36973" - else - export TF_JOB_QUEUE="${{ inputs.tf_queue }}" - fi + cat > env_setup.sh < snap_channel.txt - echo "Using store channel: $(cat snap_channel.txt)" + echo "Using store channel: ${SNAP_TEST_SOURCE}" echo "::endgroup::" fi @@ -93,20 +92,17 @@ jobs: .job_queue = env(TF_JOB_QUEUE) | .test_data.attachments = [ { "agent": "device_script.sh", "local": strenv(ROOT_DIR) + "/.github/testflinger-assets/test_snap_device_script.sh" }, + { "agent": "env_setup.sh", "local": strenv(ROOT_DIR) + "/env_setup.sh" }, { "agent": "test_data.gz", "local": strenv(ROOT_DIR) + "/test_data.gz" }, { "agent": "snap_tests.py", "local": strenv(ROOT_DIR) + "/tests/snap_tests.py" } ] ' .github/testflinger-assets/testflinger_job.yaml > job.yaml # Append source-specific attachment - if [[ "${SNAP_TEST_SOURCE}" == "artifact" ]]; then + if [[ "${SNAP_TEST_SOURCE}" == "local" ]]; then yq -i '.test_data.attachments += [ { "agent": "fpgad.snap", "local": strenv(ROOT_DIR) + "/fpgad.snap" } ]' job.yaml - else - yq -i '.test_data.attachments += [ - { "agent": "snap_channel.txt", "local": strenv(ROOT_DIR) + "/snap_channel.txt" } - ]' job.yaml fi cat job.yaml From 6bb8a3e87c66a04b312d9e63dc371e44fc104cd3 Mon Sep 17 00:00:00 2001 From: Sinan KARAKAYA Date: Mon, 30 Mar 2026 18:17:21 +0200 Subject: [PATCH 7/8] workflows: Enable manual trigger for integration tests workflow Add workflow_dispatch to allow manual execution of the integration tests via the GitHub Actions UI. Signed-off-by: Sinan KARAKAYA --- .github/testflinger-assets/env_setup.sh | 5 +++++ .github/testflinger-assets/test_snap_device_script.sh | 8 +------- .github/testflinger-assets/testflinger_job.yaml | 2 +- .github/workflows/integration_tests.yml | 1 + .github/workflows/snap_integration_tests.yml | 7 ++++--- 5 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 .github/testflinger-assets/env_setup.sh diff --git a/.github/testflinger-assets/env_setup.sh b/.github/testflinger-assets/env_setup.sh new file mode 100644 index 00000000..3ed4bd69 --- /dev/null +++ b/.github/testflinger-assets/env_setup.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Set to default values. Will be set in snap_integration_tests.yml +SNAP_TEST_SOURCE="${SNAP_TEST_SOURCE:-local}" +SNAP_CHANNEL="${SNAP_CHANNEL:-${SNAP_TEST_SOURCE}}" \ No newline at end of file diff --git a/.github/testflinger-assets/test_snap_device_script.sh b/.github/testflinger-assets/test_snap_device_script.sh index d0335a6b..514a7435 100755 --- a/.github/testflinger-assets/test_snap_device_script.sh +++ b/.github/testflinger-assets/test_snap_device_script.sh @@ -1,13 +1,7 @@ #!/usr/bin/env bash set -euxo pipefail -if [[ -f ./env_setup.sh ]]; then - # shellcheck disable=SC1091 - . ./env_setup.sh -fi - -SNAP_TEST_SOURCE="${SNAP_TEST_SOURCE:-local}" -SNAP_CHANNEL="${SNAP_CHANNEL:-${SNAP_TEST_SOURCE}}" +. ./env_setup.sh echo "INFO: Preparing device" echo " --- Updating with apt" diff --git a/.github/testflinger-assets/testflinger_job.yaml b/.github/testflinger-assets/testflinger_job.yaml index 1e17c329..1e265da8 100644 --- a/.github/testflinger-assets/testflinger_job.yaml +++ b/.github/testflinger-assets/testflinger_job.yaml @@ -51,7 +51,7 @@ test_data: # Run the test script, but always retrieve artifacts even if it fails set +e - _run 'if [ -f /home/ubuntu/env_setup.sh ]; then . /home/ubuntu/env_setup.sh; fi; /home/ubuntu/device_script.sh' + _run '/home/ubuntu/env_setup.sh; /home/ubuntu/device_script.sh' TEST_SCRIPT_EXIT=$? set -e diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index b599b599..19bc1651 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -1,5 +1,6 @@ name: Run integration tests on a DUT via testflinger on: + workflow_dispatch: pull_request: jobs: binary-integration-tests: diff --git a/.github/workflows/snap_integration_tests.yml b/.github/workflows/snap_integration_tests.yml index bbecd0b6..a4d1b909 100644 --- a/.github/workflows/snap_integration_tests.yml +++ b/.github/workflows/snap_integration_tests.yml @@ -60,11 +60,12 @@ jobs: TF_JOB_QUEUE: ${{ inputs.tf_queue || 'xilinx-kv260-c36973' }} shell: bash run: | - cat > env_setup.sh < "${ROOT_DIR}/.github/testflinger-assets/env_setup.sh" < Date: Wed, 15 Apr 2026 09:25:13 +0200 Subject: [PATCH 8/8] workflows: export snap variables and remove explicit sourcing Add export to SNAP_TEST_SOURCE and SNAP_CHANNEL in env_setup.sh to ensure they are available to subprocesses. Remove the explicit sourcing of env_setup.sh from test_snap_device_script.sh. Signed-off-by: Sinan KARAKAYA --- .github/testflinger-assets/env_setup.sh | 4 ++-- .github/testflinger-assets/test_snap_device_script.sh | 2 -- .github/testflinger-assets/testflinger_job.yaml | 4 +++- .github/workflows/integration_tests.yml | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/testflinger-assets/env_setup.sh b/.github/testflinger-assets/env_setup.sh index 3ed4bd69..6174552f 100644 --- a/.github/testflinger-assets/env_setup.sh +++ b/.github/testflinger-assets/env_setup.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash # Set to default values. Will be set in snap_integration_tests.yml -SNAP_TEST_SOURCE="${SNAP_TEST_SOURCE:-local}" -SNAP_CHANNEL="${SNAP_CHANNEL:-${SNAP_TEST_SOURCE}}" \ No newline at end of file +export SNAP_TEST_SOURCE="${SNAP_TEST_SOURCE:-local}" +export SNAP_CHANNEL="${SNAP_CHANNEL:-${SNAP_TEST_SOURCE}}" \ No newline at end of file diff --git a/.github/testflinger-assets/test_snap_device_script.sh b/.github/testflinger-assets/test_snap_device_script.sh index 514a7435..f62a1925 100755 --- a/.github/testflinger-assets/test_snap_device_script.sh +++ b/.github/testflinger-assets/test_snap_device_script.sh @@ -1,8 +1,6 @@ #!/usr/bin/env bash set -euxo pipefail -. ./env_setup.sh - echo "INFO: Preparing device" echo " --- Updating with apt" sudo env DEBIAN_FRONTEND=noninteractive apt update && sudo env DEBIAN_FRONTEND=noninteractive apt install build-essential -y diff --git a/.github/testflinger-assets/testflinger_job.yaml b/.github/testflinger-assets/testflinger_job.yaml index 1e265da8..933ddc60 100644 --- a/.github/testflinger-assets/testflinger_job.yaml +++ b/.github/testflinger-assets/testflinger_job.yaml @@ -33,6 +33,8 @@ test_data: local: ./fpgad.gz - agent: device_script.sh local: ./device_script.sh + - agent: env_setup.sh + local: ./env_setup.sh test_cmds: | set -e # get hw-cert-team helper tools @@ -51,7 +53,7 @@ test_data: # Run the test script, but always retrieve artifacts even if it fails set +e - _run '/home/ubuntu/env_setup.sh; /home/ubuntu/device_script.sh' + _run 'source /home/ubuntu/env_setup.sh && /home/ubuntu/device_script.sh' TEST_SCRIPT_EXIT=$? set -e diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 19bc1651..f2222629 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -32,7 +32,8 @@ jobs: echo "::group::creating job.yaml" yq '.test_data.attachments = [ {"agent": "device_script.sh", "local": "'"$(pwd)"'/.github/testflinger-assets/test_binary_device_script.sh"}, - {"agent": "fpgad.gz", "local": "'"$(pwd)"'/fpgad.gz"} + {"agent": "fpgad.gz", "local": "'"$(pwd)"'/fpgad.gz"}, + {"agent": "env_setup.sh", "local": "'"$(pwd)"'/.github/testflinger-assets/env_setup.sh"} ]' .github/testflinger-assets/testflinger_job.yaml | tee job.yaml echo "::endgroup::"