Skip to content

Adds github action

Adds github action #17

Workflow file for this run

name: CI
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
lint_fmt:
name: cargo fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formating
run: cargo fmt -- --check
lint_clippy:
name: Clippy
strategy:
matrix:
version: ["1.0", "1.1", "2.0", "2.1", "3.0", "3.1", "3.2", "4.0", "5.0", "6.0"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Install lxc
run: |
sudo apt update
sudo apt install lxc-dev clang meson systemd libdbus-1-dev -y
git clone https://github.com/lxc/lxc.git
cd lxc
case "${{ matrix.version }}" in
"6.0")
TAG="v6.0.0"
;;
"5.0")
TAG="lxc-5.0.3"
;;
*)
TAG="lxc-${{ matrix.version }}.0"
;;
esac
git checkout "$TAG"
if [[ $(echo "${{ matrix.version }}" | cut -d. -f1) -ge 5 ]]
then
meson setup -Dprefix=/usr -Dman=false build
meson compile -C build
sudo meson install -C build
else
./autogen.sh
./configure
sudo cp src/lxc/attach_options.h src/lxc/lxccontainer.h src/lxc/version.h /usr/include/lxc
fi
- name: Run clippy
run: |
VERSION=${{ matrix.version }}
cargo clippy --features="v${VERSION/./_}" -- --deny warnings
tests:
name: Tests
strategy:
matrix:
mode: ["debug", "release"]
version: ["1.0", "1.1", "2.0", "2.1", "3.0", "3.1", "3.2", "4.0", "5.0", "6.0"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Install lxc
run: |
sudo apt update
sudo apt install lxc-dev clang meson systemd libdbus-1-dev -y
git clone https://github.com/lxc/lxc.git
cd lxc
case "${{ matrix.version }}" in
"6.0")
TAG="v6.0.0"
;;
"5.0")
TAG="lxc-5.0.3"
;;
*)
TAG="lxc-${{ matrix.version }}.0"
;;
esac
git checkout "$TAG"
if [[ $(echo "${{ matrix.version }}" | cut -d. -f1) -ge 5 ]]
then
meson setup -Dprefix=/usr -Dman=false build
meson compile -C build
sudo meson install -C build
else
./autogen.sh
./configure
sudo cp src/lxc/attach_options.h src/lxc/lxccontainer.h src/lxc/version.h /usr/include/lxc
fi
- name: Run tests (debug)
if: matrix.mode == 'debug'
run: cargo test --features="v${version}"
- name: Run tests (release)
if: matrix.mode == 'release'
run: cargo test --features="v${version}" --release