Skip to content

Commit

Permalink
github ci: start fedora 37 for running 'cargo test'
Browse files Browse the repository at this point in the history
Signed-off-by: Ming Lei <[email protected]>
Signed-off-by: Ming Lei <[email protected]>
  • Loading branch information
ming1 authored and Ming Lei committed Aug 13, 2023
1 parent 5caaf07 commit e6a02dc
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,65 @@ jobs:
- uses: actions/checkout@v3
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo build --verbose
test:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: "install: mkosi + dependencies"
shell: bash
run: |
sudo apt update -o Acquire::Retries=3
sudo apt install -y dnf rpm systemd-container qemu-system-x86 ovmf e2fsprogs btrfs-progs
rustup update stable && rustup default stable
wget https://github.com/systemd/mkosi/archive/refs/tags/v14.tar.gz
tar zxf v14.tar.gz
cd mkosi-14
sed -i '/gpgurl\ = \urllib.parse.urljoin/c \ gpgurl\ =\ \"https://fedoraproject.org/fedora.gpg\"' ./mkosi/__init__.py
python3 -m pip install --user ./
# Required for ssh'ing into VM
- name: "setup: environment"
run: |
sudo systemctl enable --now systemd-networkd
- name: "cache: os packages"
uses: actions/cache@v3
with:
path: mkosi.cache
key: fedora-cache-v1

- name: "acquire: libublk"
uses: actions/checkout@v3

- name: "build: fedora image"
working-directory: ci
run: |
sudo $(which mkosi) build
- name: "start: boot fedora in qemu"
working-directory: ci
run: |
RUNNER_TRACKING_ID="" && sudo $(which mkosi) qemu -serial none -monitor none -display none | tee ${{ github.workspace }}/qemu.log &
- name: "connect: check ssh connection"
shell: bash
timeout-minutes: 10
working-directory: ci
run: |
until mkosi ssh uname -a; do
echo "Retrying..."
sleep 0.25
done
- name: "test: run libublk test"
working-directory: ci
run: |
mkosi ssh ls -l /usr/share/
mkosi ssh cargo test --manifest-path /usr/share/libublk-rs/Cargo.toml
- name: "cleanup"
if: always()
continue-on-error: true
run: |
cat ${{ github.workspace }}/qemu.log
sudo pkill -f qemu
3 changes: 3 additions & 0 deletions ci/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mkosi.builddir/
mkosi.output/
mkosi.cache/
24 changes: 24 additions & 0 deletions ci/mkosi.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/bash

#
# This is a build script file for OS image generation using mkosi (https://github.com/systemd/mkosi).
# It is invoked in a build environment, with the following set well-known variables:
#
# $SRCDIR
# $DESTDIR
# $BUILDDIR
#

set -eo pipefail

mkdir -p $DESTDIR/root/
echo "systemctl restart systemd-networkd" >> $DESTDIR/root/.bash_profile
chmod +x $DESTDIR/root/.bash_profile

# Copy tests into the dest
mkdir -p $DESTDIR/usr/share
cp -fr $SRCDIR $DESTDIR/usr/share/libublk-rs

cd $DESTDIR/usr/share/libublk-rs
cargo build
cd -
2 changes: 2 additions & 0 deletions ci/mkosi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Distribution]
Distribution=fedora
28 changes: 28 additions & 0 deletions ci/mkosi.default.d/10-ubdsrv.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This is a settings file for OS image generation using mkosi (https://github.com/systemd/mkosi).

[Output]
Format=gpt_btrfs
Bootable=yes
HostonlyInitrd=yes
OutputDirectory=mkosi.output
QCow2=yes

[Content]
BuildDirectory=mkosi.builddir
BuildSources=..
Cache=mkosi.cache
SourceFileTransfer=copy-git-cached
WithNetwork=yes

[Host]
QemuHeadless=yes
Netdev=yes
Ssh=yes
SshTimeout=300

[Validation]
Password=
Autologin=yes

[Partitions]
RootSize=6G
21 changes: 21 additions & 0 deletions ci/mkosi.default.d/fedora/10-fedora.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This is a settings file for OS image generation using mkosi (https://github.com/systemd/mkosi).

[Distribution]
Distribution=fedora
Release=37

[Content]
BuildPackages=
diffutils
git
libtool
make
Packages=
fio
fio-engine-libaio
util-linux
which
rust
cargo
clang
clang-devel
1 change: 1 addition & 0 deletions ci/mkosi.extra/etc/modules-load.d/ublk-drv.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ublk_drv

0 comments on commit e6a02dc

Please sign in to comment.