Skip to content

Commit b5eec82

Browse files
committed
Adds github action
1 parent 1711884 commit b5eec82

File tree

3 files changed

+133
-38
lines changed

3 files changed

+133
-38
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+
./ci lxc ${{ matrix.version }}
37+
VERSION=$(echo ${{ matrix.version }} | sed 's/\./_/'
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+
./ci lxc ${{ matrix.version }}
58+
VERSION=$(echo ${{ matrix.version }} | sed 's/\./_/'
59+
cargo test --features="${VERSION}"
60+
61+
- name: Run tests (release)
62+
if: matrix.mode == 'release'
63+
run: |
64+
$(./ci lxc ${{ matrix.version }})
65+
VERSION=$(echo ${{ matrix.version }} | sed 's/\./_/'
66+
cargo test --features="${VERSION}" --release

.gitlab-ci.yml

+6-38
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,23 @@ fmt:
1111
script:
1212
- cargo fmt -- --check
1313

14-
.common: &common
15-
before_script:
16-
- apt update
17-
- apt install lxc-dev clang meson systemd libdbus-1-dev -y
18-
19-
- git clone https://github.com/lxc/lxc.git
20-
- cd lxc
21-
- >
22-
case "$VERSION" in
23-
"6.0")
24-
TAG="v6.0.0"
25-
;;
26-
"5.0")
27-
TAG="lxc-5.0.3"
28-
;;
29-
*)
30-
TAG="lxc-$VERSION.0"
31-
;;
32-
esac
33-
- git checkout "$TAG"
34-
- >
35-
if [[ $(echo "$VERSION" | cut -d. -f1) -ge 5 ]]
36-
then
37-
meson setup -Dprefix=/usr -Dman=false build
38-
meson compile -C build
39-
meson install -C build
40-
else
41-
./autogen.sh
42-
./configure
43-
cp src/lxc/attach_options.h src/lxc/lxccontainer.h src/lxc/version.h /usr/include/lxc
44-
fi
45-
4614
clippy:
4715
parallel:
4816
matrix:
4917
- VERSION: ["1.0", "1.1", "2.0", "2.1", "3.0", "3.1", "3.2", "4.0", "5.0", "6.0"]
50-
<<: *common
5118
stage: lint
19+
before_script: ./ci lxc $VERSION
5220
script:
5321
- rustup component add clippy
54-
- cargo clippy --features="v${VERSION/./_}"
22+
- cargo clippy --features="${VERSION/./_}"
5523

5624
test:
5725
parallel:
5826
matrix:
5927
- VERSION: ["1.0", "1.1", "2.0", "2.1", "3.0", "3.1", "3.2", "4.0", "5.0", "6.0"]
60-
<<: *common
6128
stage: test
29+
before_script: ./ci lxc $VERSION
30+
6231
script:
63-
- FEATURE="v${VERSION/./_}"
64-
- cargo test --features=$FEATURE --release
65-
- cargo test --features=$FEATURE
32+
- cargo test --features="${VERSION/./_}" --release
33+
- cargo test --features="${VERSION/./_}"

ci

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
61+
main $*

0 commit comments

Comments
 (0)