diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c02b928..9425ed8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,4 @@ -name: Rust +name: Build on: push: @@ -6,40 +6,10 @@ on: 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 . diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f7257aa --- /dev/null +++ b/Dockerfile @@ -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 / diff --git a/ci.sh b/ci.sh new file mode 100755 index 0000000..a35f43b --- /dev/null +++ b/ci.sh @@ -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