Skip to content

Commit

Permalink
Add Alpine packaging and testing github action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
liveans committed Sep 22, 2024
1 parent 9c4dceb commit 56698c5
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 0 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/package-alpine-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Alpine Linux Packages

on:
workflow_dispatch:
push:
branches:
- main
- release/*
pull_request:
branches:
- main
- release/*

concurrency:
# Cancel any workflow currently in progress for the same PR.
# Allow running concurrently with any other commits.
group: package-linux-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

permissions: read-all

jobs:
build-alpine-packages:
name: Generate Alpine Packages
needs: []
strategy:
fail-fast: false
matrix:
vec: [
{ friendlyName: "Alpine-3.20-x64", config: "Release", arch: "x64", tls: "openssl3", image: "mcr.microsoft.com/dotnet/sdk:8.0-alpine3.20-amd64" },
{ friendlyName: "Alpine-3.20-ARM64", config: "Release", arch: "arm64", tls: "openssl3", image: "mcr.microsoft.com/dotnet/sdk:8.0-alpine3.20-arm64v8" },
# .NET is not working properly for ARM32 Alpine with QEMU, so keep it disabled for now.
# { friendlyName: "Alpine-3.20-ARM32", config: "Release", arch: "arm", tls: "openssl3", image: "mcr.microsoft.com/dotnet/sdk:8.0-alpine3.20-arm32v7" },
]
runs-on: ubuntu-latest
env:
REPO_TAR_URL: ${{ github.api_url }}/repos/${{ github.repository }}/tarball/${{ github.sha }}
REPO: https://github.com/microsoft/msquic
SHA: ${{ github.sha }}
TARGETARCH: ${{ matrix.vec.arch }}
REPO_URL: https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}
steps:
- name: Get Files
run: |
wget $REPO_URL/scripts/package-build.sh
mkdir artifacts
cp package-build.sh artifacts/package-build.sh
chmod +x artifacts/package-build.sh
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf
- name: Docker Run and Build Package
run: |
docker run \
-e REPO_URL=$REPO_URL \
-e REPO_TAR_URL=$REPO_TAR_URL \
-e REPO=$REPO \
-e SHA=$SHA \
-e TARGETARCH=$TARGETARCH \
-v $(pwd)/artifacts:/artifacts \
${{ matrix.vec.image }} /artifacts/package-build.sh
- name: Upload Package
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: ${{ matrix.vec.friendlyName }}-package
path: artifacts/*.apk

test-packages-on-docker:
name: Test Linux Packages
needs: [build-alpine-packages]
strategy:
fail-fast: false
matrix:
vec: [
{ friendlyName: "Alpine-3.20-x64", config: "Release", arch: "x64", tls: "openssl3", image: "mcr.microsoft.com/dotnet/runtime:9.0-alpine3.20-amd64", dotnetVersion: "9.0" },
{ friendlyName: "Alpine-3.20-ARM64", config: "Release", arch: "arm64", tls: "openssl3", image: "mcr.microsoft.com/dotnet/runtime:9.0-alpine3.20-arm64v8", dotnetVersion: "9.0" },
# { friendlyName: "Alpine-3.20-ARM32", config: "Release", arch: "arm", tls: "openssl3", image: "mcr.microsoft.com/dotnet/runtime:9.0-alpine3.20-arm32v7", dotnetVersion: "9.0" },
]
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Download Package
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: ${{ matrix.vec.friendlyName }}-package
path: artifacts
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf
- name: Set up .NET 9.0
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee
with:
dotnet-version: ${{ matrix.vec.dotnetVersion }}
- name: Build .NET QUIC Test Project
run: |
pushd src/cs/QuicSimpleTest && dotnet build QuicHello.net${{ matrix.vec.dotnetVersion }}.csproj -a ${{ matrix.vec.arch }} -c ${{ matrix.vec.config }} -o artifacts/net${{ matrix.vec.dotnetVersion }} -f net${{ matrix.vec.dotnetVersion }} && popd
- name: Docker Run
run: |
docker run -v $(pwd):/main ${{ matrix.vec.image }} /main/scripts/docker-script.sh ${{ matrix.vec.arch }} ${{ matrix.vec.config }} ${{ matrix.vec.tls }} ${{ matrix.vec.dotnetVersion }}
12 changes: 12 additions & 0 deletions docs/PackagingAlpine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Packaging MsQuic for Alpine

1. Create release and create tag with exact version number (e.g. v2.5.0).
2. Run `generate-alpine-packaging-file.ps1` script to create `APKBUILD` file for the release.
3. If you don't have account for [AlpineLinux GitLab](https://gitlab.alpinelinux.org). Create an account and [configure your SSH](https://docs.gitlab.com/ee/user/ssh.html).
4. If you didn't fork `aports` repository yet, Fork `https://gitlab.alpinelinux.org/alpine/aports`.
5. Clone `https://gitlab.alpinelinux.org/<your_username>/aports` repository.
6. Navigate to `aports/testing/libmsquic` folder.
7. Replace the `APKBUILD` file with newly created `APKBUILD` file.
8. Create a commit using `testing/libmsquic: upgrade to <version_number>` (version_number e.g. 2.5.0 or 2.4.4).
9. Create a merge request using `testing/libmsquic: upgrade to <version_number>` (version_number e.g. 2.5.0 or 2.4.4).
10. Owners of the `aports` repository will respond to the PR or merge it in couple of days/hours.
8 changes: 8 additions & 0 deletions scripts/alpine-generate-hash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#! /bin/sh
set -e
apk add --upgrade --no-cache alpine-sdk
adduser -D packaging -G abuild
cp /msquic/APKBUILD /home/packaging/
cd /home/packaging
su packaging -c "abuild checksum"
cp /home/packaging/APKBUILD /msquic/APKBUILD
36 changes: 36 additions & 0 deletions scripts/generate-alpine-packaging-file.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
class Version
{
[string]$Major
[string]$Minor
[string]$Patch
}

$submodules = git submodule

$processedSubmodules = @("clog", "openssl3", "googletest")
$placeholderVariables = @{
"clog" = "CLOG_COMMIT_HASH"
"openssl3" = "OPENSSL3_COMMIT_HASH"
"googletest" = "GOOGLETEST_COMMIT_HASH"
}
$versionPlaceholder = "VERSION_PLACEHOLDER"
$alpinePackagingFile = ((Get-Content "$PSScriptRoot/templates/APKBUILD.template") -join "`n") + "`n"

foreach ($submodule in $submodules)
{
$submoduleInfo = $submodule.Trim().Split(" ")
$submoduleName = $submoduleInfo[1].Replace("submodules/", "")
if ($processedSubmodules -contains $submoduleName)
{
$alpinePackagingFile = $alpinePackagingFile -replace $placeholderVariables[$submoduleName], $submoduleInfo[0]
}
}

$version = [Version](Get-Content 'version.json' | Out-String | ConvertFrom-Json)
$alpinePackagingFile = $alpinePackagingFile -replace $versionPlaceholder, "$($version.Major).$($version.Minor).$($version.Patch)"
Write-Output $alpinePackagingFile | Out-File APKBUILD -NoNewline
Write-Output "APKBUILD file for msquic v$($version.Major).$($version.Minor).$($version.Patch) has been generated successfully."
Write-Output "Starting to add file hashes into APKBUILD file..."

docker run -v .:/msquic -w /msquic alpine:latest /msquic/scripts/alpine-generate-hash.sh
Write-Output "File hashes have been added successfully."
54 changes: 54 additions & 0 deletions scripts/templates/APKBUILD.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Contributor: Ahmet Ibrahim AKSOY <aaksoy@microsoft.com>
# Maintainer: Microsoft QUIC Team <quicdev@microsoft.com>
pkgname=libmsquic
pkgver=VERSION_PLACEHOLDER
pkgrel=0
_clog=CLOG_COMMIT_HASH
_gtest=GOOGLETEST_COMMIT_HASH
_openssl3=OPENSSL3_COMMIT_HASH
pkgdesc="Cross-platform, C implementation of the IETF QUIC protocol, exposed to C, C++, C# and Rust."
url="https://github.com/microsoft/msquic"
arch="x86_64 armv7 aarch64"
license="MIT"
makedepends="cmake numactl-dev linux-headers lttng-ust-dev openssl-dev perl xz"
checkdepends="perf"
subpackages="$pkgname-dev $pkgname-doc"
source="msquic-$pkgver.tar.gz::https://github.com/microsoft/msquic/archive/refs/tags/v$pkgver.tar.gz
clog-$_clog.tar.gz::https://github.com/microsoft/CLOG/archive/$_clog.tar.gz
gtest-$_gtest.tar.gz::https://github.com/google/googletest/archive/$_gtest.tar.gz
openssl3-$_openssl3.tar.gz::https://github.com/quictls/openssl/archive/$_openssl3.tar.gz
"
builddir="$srcdir/msquic-$pkgver"

prepare() {
default_prepare

cd "$builddir/submodules"
rm -rf clog googletest openssl openssl3 xdp-for-windows
mv ../../CLOG-*/ clog/
mv ../../googletest-*/ googletest/
mv ../../openssl-*/ openssl3/
}

build() {
cmake -B build \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DQUIC_TLS=openssl3 \
-DQUIC_ENABLE_LOGGING=true \
-DQUIC_USE_SYSTEM_LIBCRYPTO=true \
-DQUIC_BUILD_TOOLS=off \
-DQUIC_BUILD_TEST=on \
-DQUIC_BUILD_PERF=off
cmake --build build
}

check() {
build/bin/Release/msquictest --gtest_filter=ParameterValidation.ValidateApi
}

package() {
DESTDIR="$pkgdir" cmake --install build
rm -rf "$pkgdir"/usr/share/msquic/
install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

0 comments on commit 56698c5

Please sign in to comment.