-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use docker to make reliable CI environment
- Loading branch information
Showing
3 changed files
with
59 additions
and
34 deletions.
There are no files selected for viewing
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
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 . |
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
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 / |
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
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 |