Skip to content

Commit 3fea0ce

Browse files
committed
Adds github action
1 parent 1711884 commit 3fea0ce

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

.github/workflows/ci.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
8+
jobs:
9+
lint_fmt:
10+
name: cargo fmt
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: dtolnay/rust-toolchain@stable
16+
with:
17+
components: rustfmt
18+
- name: Check formating
19+
run: cargo fmt -- --check
20+
21+
lint_clippy:
22+
name: Clippy
23+
strategy:
24+
matrix:
25+
version: ["1.0", "1.1", "2.0", "2.1", "3.0", "3.1", "3.2", "4.0", "5.0", "6.0"]
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: dtolnay/rust-toolchain@stable
31+
with:
32+
components: clippy
33+
34+
- name: Run clippy
35+
run: |
36+
VERSION=$(./ci lxc ${{ matrix.version }})
37+
echo $VERSION
38+
cargo clippy --features="${VERSION}" -- --deny warnings
39+
40+
tests:
41+
name: Tests
42+
strategy:
43+
matrix:
44+
mode: ["debug", "release"]
45+
version: ["1.0", "1.1", "2.0", "2.1", "3.0", "3.1", "3.2", "4.0", "5.0", "6.0"]
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
- uses: dtolnay/rust-toolchain@stable
51+
with:
52+
toolchain: stable
53+
54+
- name: Run tests (debug)
55+
if: matrix.mode == 'debug'
56+
run: |
57+
VERSION=$(./ci lxc ${{ matrix.version }})
58+
echo $VERSION
59+
cargo test --features="${VERSION}"
60+
61+
- name: Run tests (release)
62+
if: matrix.mode == 'release'
63+
run: |
64+
VERSION=$(./ci lxc ${{ matrix.version }})
65+
echo $VERSION
66+
cargo test --features="${VERSION}" --release

ci

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
main()
6+
{
7+
if [ $# -lt 1 ]
8+
then
9+
err "Missing argument"
10+
fi
11+
12+
local action=$1
13+
shift
14+
15+
eval "$action $*"
16+
}
17+
18+
err()
19+
{
20+
>&2 echo $*
21+
exit 1
22+
}
23+
24+
lxc()
25+
{
26+
if [ $# -lt 1 ]
27+
then
28+
err "Missing argument"
29+
fi
30+
31+
local version=$1
32+
33+
sudo apt update
34+
sudo apt install lxc-dev clang meson systemd libdbus-1-dev -y
35+
git clone https://github.com/lxc/lxc.git
36+
cd lxc
37+
case "$version" in
38+
"6.0")
39+
tag="v6.0.0"
40+
;;
41+
"5.0")
42+
tag="lxc-5.0.3"
43+
;;
44+
*)
45+
tag="lxc-$version.0"
46+
;;
47+
esac
48+
git checkout "$tag"
49+
if [ $(echo "$version" | cut -d. -f1) -ge 5 ]
50+
then
51+
meson setup -Dprefix=/usr -Dman=false build
52+
meson compile -C build
53+
sudo meson install -C build
54+
else
55+
./autogen.sh
56+
./configure
57+
sudo cp src/lxc/attach_options.h src/lxc/lxccontainer.h src/lxc/version.h /usr/include/lxc
58+
fi
59+
60+
echo "v$version" | sed 's/\./_/'
61+
}
62+
63+
main $*

0 commit comments

Comments
 (0)