feat(gh-actions): Add run-autopkgtest action #181
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test build debian package | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- gh-actions/common/build-debian/** | |
- gh-actions/common/run-autopkgtest/** | |
- .github/workflows/test-build-deb* | |
pull_request: | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
DEBCONF_NONINTERACTIVE_SEEN: true | |
jobs: | |
build_native_deb: | |
name: Test build native debian package | |
runs-on: ubuntu-latest | |
env: | |
UBUNTU_IMAGE: ubuntu:devel | |
outputs: | |
pkg-name: ${{ env.PKG_NAME }} | |
pkg-version: ${{ env.PKG_VERSION }} | |
pkg-src-changes: ${{ env.PKG_SOURCE_CHANGES }} | |
run-id: ${{ github.run_id }} | |
ubuntu-image: ${{ env.UBUNTU_IMAGE }} | |
steps: | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install ubuntu-dev-tools | |
- name: Get and prepare package source | |
run: | | |
set -eu | |
echo "::group::Get source" | |
pull-lp-source --download-only hello | |
dpkg-source -x hello*.dsc hello-src | |
rm -rf hello_* | |
mv -v hello-src/* . | |
echo "::endgroup::" | |
echo "::group::Mark package as a native package" | |
echo "3.0 (native)" > debian/source/format | |
dch -v$(dpkg-parsechangelog -S Version | cut -f1 -d-).1 \ | |
"Mark as native package" | |
echo "::endgroup::" | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
path: .source | |
- name: Build package | |
uses: ./.source/gh-actions/common/build-debian | |
with: | |
docker-image: ${{ env.UBUNTU_IMAGE }} | |
run_autopkgtest_from_src_and_binaries: | |
name: Run autopkgtests from source and binaries | |
needs: build_native_deb | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
run-id: ${{ needs.build_native_deb.outputs.run-id }} | |
merge-multiple: true | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
path: .source | |
- name: Run autopkgtests | |
uses: ./.source/gh-actions/common/run-autopkgtest | |
with: | |
source-changes: ${{ needs.build_native_deb.outputs.pkg-src-changes }} | |
lxd-image: ${{ needs.build_native_deb.outputs.ubuntu-image }} | |
build_source_deb_source: | |
name: Test build quilt debian package source | |
runs-on: ubuntu-latest | |
env: | |
UBUNTU_IMAGE: ubuntu:latest | |
outputs: | |
pkg-name: ${{ env.PKG_NAME }} | |
pkg-version: ${{ env.PKG_VERSION }} | |
pkg-dsc: ${{ env.PKG_DSC }} | |
pkg-src-changes: ${{ env.PKG_SOURCE_CHANGES }} | |
source-pkg: ${{ steps.build-debian-source-package-upload-step.outputs.artifact-url }} | |
ubuntu-image: ${{ env.UBUNTU_IMAGE }} | |
run-id: ${{ github.run_id }} | |
steps: | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install ubuntu-dev-tools | |
- name: Get package source | |
run: | | |
set -eu | |
pull-lp-source --download-only hello | |
dpkg-source -x hello*.dsc hello-src | |
rm -rfv hello_*.{dsc,debian.}* | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
path: .source | |
- name: Build source package | |
uses: ./.source/gh-actions/common/build-debian | |
with: | |
docker-image: ${{ env.UBUNTU_IMAGE }} | |
sources-only: true | |
source-dir: ./hello-src | |
build_source_deb: | |
name: Test build quilt debian package binaries | |
needs: build_source_deb_source | |
runs-on: ubuntu-latest | |
outputs: | |
binaries: ${{ steps.build-debian-binary-packages-upload-step.outputs.artifact-url }} | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
run-id: ${{ needs.build_source_deb.outputs.run-id }} | |
merge-multiple: true | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
path: .source | |
- name: Build debian package | |
uses: ./.source/gh-actions/common/build-debian | |
with: | |
from-sources-file: ${{ needs.build_source_deb_source.outputs.pkg-dsc }} | |
docker-image: ${{ needs.build_source_deb_source.outputs.ubuntu-image }} | |
lintian: --fail-on error | |
extra-source-build-deps: '' | |
extra-source-build-script: | | |
echo '$HOME' is "${HOME}" | |
echo "::group::Get some system information" | |
uname -a | |
cat /etc/os-release | |
echo "::endgroup::" | |
run_autopkgtest_from_sources: | |
name: Run autopkgtests from source package | |
needs: build_source_deb_source | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
run-id: ${{ needs.build_source_deb.outputs.run-id }} | |
merge-multiple: true | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
path: .source | |
- name: Run autopkgtests | |
uses: ./.source/gh-actions/common/run-autopkgtest | |
with: | |
source-changes: ${{ needs.build_source_deb_source.outputs.pkg-src-changes }} | |
lxd-image: ${{ needs.build_source_deb_source.outputs.image }} | |
lintian-to-md: | |
name: Test lintian results parser to markdown | |
runs-on: ubuntu-latest | |
container: | |
image: ubuntu:rolling | |
steps: | |
- name: Install dependencies | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
set -eu | |
apt update -y | |
apt install -y lintian | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Create test input | |
shell: bash | |
env: | |
NUMBER_OF_RANDOM_TAGS: 50 | |
run: | | |
set -eu | |
test_tags=$(mktemp) | |
mapfile -t tags < <(lintian-explain-tags -l | shuf | head -n${NUMBER_OF_RANDOM_TAGS}) | |
tags+=( | |
# Tags with edge cases to test | |
debhelper-compat-level | |
init.d-script-missing-lsb-keyword | |
team/pkg-js/testsuite/no-testsuite-header | |
) | |
for tag in "${tags[@]}"; do | |
lintian_line=$(lintian-explain-tags "${tag}" --output-width 80 | \ | |
sed -n "s/^\([^N]\): \(.*\)/\1: package-$RANDOM: \2/p"); | |
if [ $((RANDOM%2)) -ne 0 ]; then | |
lintian_line+=" with some random data [$RANDOM]" | |
fi | |
echo "${lintian_line}" | tee -a "${test_tags}" | |
test "${PIPESTATUS[1]}" -eq 0 | |
done | |
echo TEST_TAGS="${test_tags}" >> "${GITHUB_ENV}" | |
- name: Test lintian markdown parser | |
shell: bash | |
run: | | |
set -eu | |
cat "${{ env.TEST_TAGS }}" | \ | |
./gh-actions/common/build-debian/lintian-to-md.sh | | |
tee -a "${GITHUB_STEP_SUMMARY}" | |
pipe_status=(${PIPESTATUS[@]}) | |
for s in ${pipe_status[@]}; do | |
echo "Pipe return value: $s" | |
test "${s}" -eq 0 | |
done |