Skip to content

Support sparse files in tar and qcow2 output #999

Support sparse files in tar and qcow2 output

Support sparse files in tar and qcow2 output #999

Workflow file for this run

name: Tests
on: [pull_request]
jobs:
snap-build-amd64:
runs-on: ubuntu-24.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-amd64
path: "*.snap"
if-no-files-found: error
snap-build-arm64:
runs-on: [self-hosted, ARM64, noble, Linux]
# 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-arm64
path: "*.snap"
if-no-files-found: error
spread:
name: Build a ${{ matrix.series }} image on ${{ matrix.group }} (${{ matrix.systems }})
runs-on: [self-hosted, ubuntu-image]
needs: [snap-build-amd64, snap-build-arm64]
strategy:
fail-fast: false
matrix:
include:
- group: ubuntu-devel
series: oracular
arch: amd64
systems: 'ubuntu-24.04-64'
tests: 'tests/commons/... tests/amd64/...'
- group: ubuntu-devel-crossbuild
series: oracular
arch: amd64
systems: 'ubuntu-24.04-64'
tests: 'tests/amd64-crossbuild/...'
- group: ubuntu-latest
series: noble
arch: amd64
systems: 'ubuntu-24.04-64'
tests: 'tests/amd64/...'
- group: ubuntu-latest-crossbuild
series: noble
arch: amd64
systems: 'ubuntu-24.04-64'
tests: 'tests/amd64-crossbuild/...'
- group: ubuntu-old
series: noble
arch: amd64
systems: 'ubuntu-20.04-64 ubuntu-22.04-64'
tests: 'tests/commons/... tests/amd64/...'
- group: ubuntu-arm-devel
series: oracular
arch: arm64
systems: 'ubuntu-24.04-arm-64'
tests: 'tests/commons/... tests/arm64/...'
- group: ubuntu-arm-latest
series: noble
arch: arm64
systems: 'ubuntu-24.04-arm-64'
tests: 'tests/arm64/...'
- group: ubuntu-arm-old
series: noble
arch: arm64
systems: 'ubuntu-20.04-arm-64 ubuntu-22.04-arm-64'
tests: 'tests/commons/... tests/arm64/...'
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 previously built artifacts
uses: actions/download-artifact@v4
with:
pattern: snap-${{ matrix.arch }}
merge-multiple: true
- 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
SERIES=${{ matrix.series }}
if [[ "${{ matrix.systems }}" =~ -arm- ]]; then
BACKEND=google-arm
elif [[ "${{ matrix.group }}" =~ -crossbuild ]]; then
BACKEND=google-crossbuild
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
for TESTS in ${{ matrix.tests }}; do
RUN_TESTS="$RUN_TESTS $BACKEND:$SYSTEM:$TESTS"
done
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 }}"