Skip to content

snapcraft.yaml: Fix config installation #929

snapcraft.yaml: Fix config installation

snapcraft.yaml: Fix config installation #929

Workflow file for this run

name: Run a spread test of the generated snap
on: [pull_request]
jobs:
snap-builds:
runs-on: ubuntu-22.04
# Only build the snap for pull requests, it's not needed on release branches
# or on master since we have launchpad build recipes which do this already
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build ubuntu-image snap
uses: snapcore/action-build@v1
- name: Uploading ubuntu-image snap artifact
uses: actions/upload-artifact@v4
with:
name: snap
path: "*.snap"
spread:
runs-on: [self-hosted, ubuntu-image]
needs: snap-builds
strategy:
fail-fast: false
matrix:
include:
- group: ubuntu-arm
systems: 'ubuntu-20.04-arm-64 ubuntu-22.04-arm-64 ubuntu-24.04-arm-64'
- group: ubuntu
systems: 'ubuntu-18.04-64 ubuntu-20.04-64 ubuntu-22.04-64 ubuntu-23.10-64 ubuntu-24.04-64'
steps:
- name: Cleanup job workspace
id: cleanup-job-workspace
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get previous attempt
id: get-previous-attempt
run: |
echo "previous_attempt=$(( ${{ github.run_attempt }} - 1 ))" >> $GITHUB_OUTPUT
shell: bash
- name: Get previous cache
uses: actions/cache@v4
with:
path: "${{ github.workspace }}/.test-results"
key: "${{ github.job }}-results-${{ github.run_id }}-${{ matrix.group }}-${{ steps.get-previous-attempt.outputs.previous_attempt }}"
# Needed for some older series we are unable to build the snap on anymore
- name: Download previsouly build artifact
uses: actions/download-artifact@v4
with:
name: snap
- name: Prepare test results env and vars
id: prepare-test-results-env
run: |
# Create test results directories and save vars
TEST_RESULTS_DIR="${{ github.workspace }}/.test-results"
echo "TEST_RESULTS_DIR=$TEST_RESULTS_DIR" >> $GITHUB_ENV
# Save the var with the failed tests file
echo "FAILED_TESTS_FILE=$TEST_RESULTS_DIR/failed-tests" >> $GITHUB_ENV
# Make sure the test results dirs are created
# This step has to be after the cache is restored
mkdir -p "$TEST_RESULTS_DIR"
- name: Check failed tests to run
if: "!contains(github.event.pull_request.labels.*.name, 'Run all')"
run: |
# Save previous failed test results in FAILED_TESTS env var
FAILED_TESTS=""
if [ -f "$FAILED_TESTS_FILE" ]; then
echo "Failed tests file found"
FAILED_TESTS="$(cat $FAILED_TESTS_FILE)"
if [ -n "$FAILED_TESTS" ]; then
echo "Failed tests to run: $FAILED_TESTS"
echo "FAILED_TESTS=$FAILED_TESTS" >> $GITHUB_ENV
fi
fi
- name: Run spread tests
if: "!contains(github.event.pull_request.labels.*.name, 'Skip spread')"
run: |
# Register a problem matcher to highlight spread failures
echo "::add-matcher::.github/spread-problem-matcher.json"
BACKEND=google
SPREAD=spread
if [[ "${{ matrix.systems }}" =~ -arm- ]]; then
BACKEND=google-arm
SPREAD=spread-arm
fi
RUN_TESTS=""
# Save previous failed test results in FAILED_TESTS env var
if [ -n "$FAILED_TESTS" ]; then
RUN_TESTS="$FAILED_TESTS"
else
for SYSTEM in ${{ matrix.systems }}; do
RUN_TESTS="$RUN_TESTS $BACKEND:$SYSTEM:tests/..."
done
fi
# Run spread tests
# "pipefail" ensures that a non-zero status from the spread is
# propagated; and we use a subshell as this option could trigger
# undesired changes elsewhere
echo "Running command: $SPREAD $RUN_TESTS"
(set -o pipefail; $SPREAD $RUN_TESTS | tee spread.log)
- name: Discard spread workers
if: always()
run: |
shopt -s nullglob;
for r in .spread-reuse.*.yaml; do
spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')";
done
- name: analyze spread test results
if: always()
run: |
if [ -f spread.log ]; then
echo "Running spread log parser"
./tests/lib/external/snapd-testing-tools/utils/log-parser spread.log --output spread-results.json
BACKEND=google
if [[ "${{ matrix.systems }}" =~ -arm- ]]; then
BACKEND=google-arm
fi
echo "Determining which tests were executed"
RUN_TESTS=""
for SYSTEM in ${{ matrix.systems }}; do
RUN_TESTS="$RUN_TESTS $BACKEND:$SYSTEM:tests/..."
done
if [ -n "$FAILED_TESTS" ]; then
RUN_TESTS="$FAILED_TESTS"
fi
echo "Running spread log analyzer"
./tests/lib/external/snapd-testing-tools/utils/log-analyzer list-reexecute-tasks "$RUN_TESTS" spread-results.json > "$FAILED_TESTS_FILE"
echo "List of failed tests saved"
cat "$FAILED_TESTS_FILE"
else
echo "No spread log found, saving empty list of failed tests"
touch "$FAILED_TESTS_FILE"
fi
- name: save spread test results to cache
if: always()
uses: actions/cache/save@v4
with:
path: "${{ github.workspace }}/.test-results"
key: "${{ github.job }}-results-${{ github.run_id }}-${{ matrix.group }}-${{ github.run_attempt }}"