Skip to content

Commit fb1a8f9

Browse files
committed
build: Add CI/CD configuration based on Alpine
1 parent 3e573d6 commit fb1a8f9

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

.github/workflows/hydrun.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: hydrun CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: "0 0 * * 0"
8+
9+
jobs:
10+
build-linux:
11+
runs-on: ${{ matrix.target.runner }}
12+
permissions:
13+
contents: read
14+
strategy:
15+
matrix:
16+
target:
17+
# Binaries
18+
- id: rust.x86_64
19+
src: .
20+
os: alpine:edge
21+
flags: ""
22+
cmd: ./Hydrunfile rust x86_64
23+
dst: out/*
24+
runner: depot-ubuntu-22.04-32
25+
- id: rust.aarch64
26+
src: .
27+
os: alpine:edge
28+
flags: ""
29+
cmd: ./Hydrunfile rust aarch64
30+
dst: out/*
31+
runner: depot-ubuntu-22.04-arm-32
32+
33+
steps:
34+
- name: Maximize build space
35+
run: |
36+
sudo rm -rf /usr/share/dotnet
37+
sudo rm -rf /usr/local/lib/android
38+
sudo rm -rf /opt/ghc
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
- name: Restore ccache
42+
uses: actions/cache/restore@v4
43+
with:
44+
path: |
45+
/tmp/ccache
46+
key: cache-ccache-${{ matrix.target.id }}
47+
- name: Set up QEMU
48+
uses: docker/setup-qemu-action@v3
49+
- name: Set up Docker Buildx
50+
uses: docker/setup-buildx-action@v3
51+
- name: Set up hydrun
52+
run: |
53+
curl -L -o /tmp/hydrun "https://github.com/pojntfx/hydrun/releases/latest/download/hydrun.linux-$(uname -m)"
54+
sudo install /tmp/hydrun /usr/local/bin
55+
- name: Build with hydrun
56+
working-directory: ${{ matrix.target.src }}
57+
run: hydrun -o ${{ matrix.target.os }} ${{ matrix.target.flags }} "${{ matrix.target.cmd }}"
58+
- name: Fix permissions for output
59+
run: sudo chown -R $USER .
60+
- name: Save ccache
61+
uses: actions/cache/save@v4
62+
with:
63+
path: |
64+
/tmp/ccache
65+
key: cache-ccache-${{ matrix.target.id }}
66+
- name: Upload output
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: ${{ matrix.target.id }}
70+
path: ${{ matrix.target.dst }}
71+
72+
publish-linux:
73+
runs-on: ubuntu-latest
74+
permissions:
75+
contents: write
76+
needs: build-linux
77+
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v4
81+
- name: Download output
82+
uses: actions/download-artifact@v4
83+
with:
84+
path: /tmp/out
85+
- name: Extract branch name
86+
id: extract_branch
87+
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
88+
- name: Publish pre-release to GitHub releases
89+
if: ${{ github.ref == 'refs/heads/firecracker-v1.6-live-migration' || github.ref == 'refs/heads/firecracker-v1.6-live-migration-and-pvm' || github.ref == 'refs/heads/firecracker-v1.7-live-migration-and-msync' || github.ref == 'refs/heads/firecracker-v1.7-live-migration-pvm-and-msync' || github.ref == 'refs/heads/main-live-migration-and-msync' }}
90+
uses: marvinpinto/action-automatic-releases@latest
91+
with:
92+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
93+
automatic_release_tag: release-${{ steps.extract_branch.outputs.branch }}
94+
prerelease: true
95+
files: |
96+
/tmp/out/*/*
97+
- name: Publish release to GitHub releases
98+
if: startsWith(github.ref, 'refs/tags/v')
99+
uses: marvinpinto/action-automatic-releases@latest
100+
with:
101+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
102+
prerelease: false
103+
files: |
104+
/tmp/out/*/*

Hydrunfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Rust
6+
if [ "$1" = "rust" ]; then
7+
# Install native dependencies
8+
apk add rust cargo clang-dev cmake linux-headers make git
9+
10+
# Configure Git
11+
git config --global --add safe.directory '*'
12+
13+
# Build
14+
cp "resources/seccomp/$2-unknown-linux-musl.json" "resources/seccomp/$2-alpine-linux-musl.json"
15+
export RUSTFLAGS='-C target-feature=+crt-static'
16+
cargo build --target "$2-alpine-linux-musl" --all-features --release
17+
18+
# Stage binaries
19+
mkdir -p out
20+
21+
dir="./build/cargo_target/$2-alpine-linux-musl/release"
22+
for file in $(ls "$dir"); do
23+
if [[ -x "$dir/$file" && ! -d "$dir/$file" ]]; then
24+
cp "$dir/$file" "./out/${file}.linux-$2"
25+
fi
26+
done
27+
28+
exit 0
29+
fi

0 commit comments

Comments
 (0)