Skip to content

Commit

Permalink
Feature docker ci (#70)
Browse files Browse the repository at this point in the history
Use docker to make reliable CI environment
  • Loading branch information
leeopop authored Feb 19, 2024
1 parent ac2c98f commit 264ffc1
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 34 deletions.
38 changes: 4 additions & 34 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,15 @@
name: Rust
name: Build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always
DPDK_VERSION: 22.11.4

jobs:
build:
runs-on: self-hosted
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt update && sudo apt install -y linux-headers-generic build-essential libnuma-dev git meson python3-pyelftools curl libclang-dev clang llvm-dev libbsd-dev
- name: Install DPDK
run: |
wget -O dpdk.tar.xz https://fast.dpdk.org/rel/dpdk-${DPDK_VERSION}.tar.xz
mkdir dpdk-src
tar -xvJf dpdk.tar.xz -C dpdk-src --strip-components=1
cd dpdk-src
meson setup build
ninja -C build
sudo ninja -C build install
sudo ldconfig
rm -rf dpdk-src
- name: Install minimal Rust with clippy and rustfmt
run: |
curl -f -sSf https://sh.rustup.rs | bash -s -- -y --profile minimal --component clippy rustfmt
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Check
run: |
clang --version
llvm-config --version
cargo --version
gcc --version
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Dockerized CI
run: docker build --progress=plain .
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM debian:latest

WORKDIR /
RUN echo "APT last updated: 2024/01/01"

RUN apt-get update -y && apt-get dist-upgrade -y && apt-get autoremove -y && apt-get autoclean -y
RUN apt-get install -y linux-headers-generic build-essential libnuma-dev git meson python3-pyelftools curl libclang-dev clang llvm-dev libbsd-dev
RUN apt-get install -y curl git tar

ENV RTE_SDK=/usr/local/share/dpdk
ENV DPDK_VERSION 22.11.4

# Install DPDK
RUN mkdir /dpdk
RUN curl -s -o dpdk.tar.xz https://fast.dpdk.org/rel/dpdk-${DPDK_VERSION}.tar.xz
RUN tar -xvJf dpdk.tar.xz -C dpdk --strip-components=1
WORKDIR /dpdk
RUN meson setup build
RUN ninja -C build
RUN ninja -C build install
RUN ldconfig
WORKDIR /
RUN rm -rf /dpdk

# Init user account
ENV USER_NAME user
RUN useradd -ms /bin/bash $USER_NAME

# Rust user install
WORKDIR /home/$USER_NAME
RUN su -c "curl -f -sSf https://sh.rustup.rs | bash -s -- -y --default-toolchain none" - $USER_NAME
ADD ./rust-toolchain /
RUN chmod 444 /rust-toolchain
RUN su -c "rustup toolchain install `cat /rust-toolchain | tr -d ' \n'` --profile minimal --component clippy rustfmt" - $USER_NAME
RUN rm /rust-toolchain
WORKDIR /

# User ci script
ADD . /home/$USER_NAME/
RUN chown -R $USER_NAME:$USER_NAME /home/$USER_NAME
WORKDIR /home/$USER_NAME
RUN su -c "./ci.sh" - $USER_NAME
WORKDIR /
12 changes: 12 additions & 0 deletions ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -x

# Check program version
clang --version
llvm-config --version
cargo --version
gcc --version

# Build and test
cargo build --verbose
cargo test --verbose

0 comments on commit 264ffc1

Please sign in to comment.