Skip to content

Update ubuntu Docker tag to v26 #180

Update ubuntu Docker tag to v26

Update ubuntu Docker tag to v26 #180

Workflow file for this run

name: Multi-OS Package Manager Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
# Docker-based tests for different OS/package manager combinations
docker-tests:
name: Docker Tests (${{ matrix.os }}-${{ matrix.pm }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu
pm: apt
dockerfile: ubuntu.Dockerfile
test_tags: "unit,integration,apt"
- os: rockylinux
pm: yum
dockerfile: rockylinux.Dockerfile
test_tags: "unit,integration,yum"
# TODO: Enable when DNF support is implemented
# - os: fedora
# pm: dnf
# dockerfile: fedora.Dockerfile
# test_tags: "unit,integration,dnf"
# TODO: Enable when APK support is implemented
# - os: alpine
# pm: apk
# dockerfile: alpine.Dockerfile
# test_tags: "unit,integration,apk"
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build test container
run: |
docker build -f testing/docker/${{ matrix.dockerfile }} \
-t syspkg-test-${{ matrix.os }}:latest .
- name: Run container tests
run: |
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-e TEST_OS=${{ matrix.os }} \
-e TEST_PACKAGE_MANAGER=${{ matrix.pm }} \
-e IN_CONTAINER=true \
syspkg-test-${{ matrix.os }}:latest \
go test -v -tags="${{ matrix.test_tags }}" ./manager/${{ matrix.pm }} ./osinfo
- name: Generate test fixtures
run: |
docker run --rm \
-v ${{ github.workspace }}:/workspace \
syspkg-test-${{ matrix.os }}:latest \
bash -c "
mkdir -p testing/fixtures/${{ matrix.pm }}
case '${{ matrix.pm }}' in
apt)
apt update 2>/dev/null
apt search vim > testing/fixtures/apt/search-vim-${{ matrix.os }}.txt 2>/dev/null || true
apt show vim > testing/fixtures/apt/show-vim-${{ matrix.os }}.txt 2>/dev/null || true
;;
yum)
yum search vim > testing/fixtures/yum/search-vim-${{ matrix.os }}.txt 2>/dev/null || true
yum info vim > testing/fixtures/yum/info-vim-${{ matrix.os }}.txt 2>/dev/null || true
;;
dnf)
dnf search vim > testing/fixtures/dnf/search-vim-${{ matrix.os }}.txt 2>/dev/null || true
dnf info vim > testing/fixtures/dnf/info-vim-${{ matrix.os }}.txt 2>/dev/null || true
;;
apk)
apk update 2>/dev/null
apk search vim > testing/fixtures/apk/search-vim-${{ matrix.os }}.txt 2>/dev/null || true
apk info vim > testing/fixtures/apk/info-vim-${{ matrix.os }}.txt 2>/dev/null || true
;;
esac
"
- name: Upload test fixtures
uses: actions/upload-artifact@v7
with:
name: test-fixtures-${{ matrix.os }}-${{ matrix.pm }}
path: testing/fixtures/
retention-days: 30
# Native runner tests for package managers requiring systemd/privileges
native-tests:
name: Native Tests (${{ matrix.os }}-${{ matrix.pm }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu
runner: ubuntu-latest
pm: apt
setup: |
sudo apt update
sudo apt install -y flatpak
- os: ubuntu
runner: ubuntu-latest
pm: snap
setup: |
sudo systemctl start snapd
sudo snap wait system seed.loaded
- os: ubuntu
runner: ubuntu-latest
pm: flatpak
setup: |
sudo apt update
sudo apt install -y flatpak
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Setup package manager
run: ${{ matrix.setup }}
- name: Run integration tests
run: |
go test -v -tags="integration,system" ./manager/${{ matrix.pm }}
- name: Run full system tests (if applicable)
if: matrix.pm != 'snap' # Skip snap system tests to avoid conflicts
run: |
# Test basic operations that don't require actual installs
go test -v -run="TestIsAvailable|TestList|TestSearch" ./manager/${{ matrix.pm }}
# OS detection tests across different environments
os-detection-tests:
name: OS Detection Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Test OS detection in different containers
run: |
# Test Ubuntu detection
docker run --rm -v $PWD:/workspace ubuntu:22.04 bash -c "
apt-get update && apt-get install -y curl &&
cd /workspace &&
curl -L https://go.dev/dl/go1.23.4.linux-amd64.tar.gz | tar -C /usr/local -xz &&
/usr/local/go/bin/go test -v ./osinfo -run TestGetOSInfo
"
# Test Alpine detection
docker run --rm -v $PWD:/workspace alpine:3.18 sh -c "
cd /workspace &&
apk add --no-cache curl tar &&
curl -L https://go.dev/dl/go1.23.4.linux-amd64.tar.gz | tar -C /usr/local -xz &&
/usr/local/go/bin/go test -v ./osinfo -run TestGetOSInfo
"
# Summary job that depends on all tests
test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [docker-tests, native-tests, os-detection-tests]
if: always()
steps:
- name: Check test results
run: |
echo "Docker tests: ${{ needs.docker-tests.result }}"
echo "Native tests: ${{ needs.native-tests.result }}"
echo "OS detection tests: ${{ needs.os-detection-tests.result }}"
if [[ "${{ needs.docker-tests.result }}" == "failure" ||
"${{ needs.native-tests.result }}" == "failure" ||
"${{ needs.os-detection-tests.result }}" == "failure" ]]; then
echo "Some tests failed"
exit 1
fi
echo "All tests passed!"