-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (123 loc) · 4.04 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Build and Lint pmacct-gauze
on:
push:
branches:
- master
pull_request:
branches:
- master
schedule: [ cron: "40 1 * * *" ]
jobs:
build:
runs-on: ubuntu-latest
env:
# Set PMACCT_INCLUDE_DIR to the parent directory of the pmacct folder
ROOT: ${{ github.workspace }}
PMACCT_INCLUDE_DIR: ${{ github.workspace }}
PMACCT_GAUZE_BUILD_DIR: "${{ github.workspace }}/build-target"
steps:
# Step 1: Checkout pmacct-gauze repository (this repository) on master branch
- name: Checkout pmacct-gauze repository
uses: actions/checkout@v3
with:
ref: master
# Step 2: Clone the pmacct project and checkout netgauze-exp branch
- name: Clone pmacct repository on branch netgauze-exp
run: |
git clone --recurse-submodules -b netgauze-exp https://github.com/mxyns/pmacct/
# Step 3: Set up C environment (libcdada and pmacct dependencies)
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
autoconf \
libtool \
pkg-config \
libpcap-dev \
libnetfilter-queue-dev \
libjson-c-dev \
libmnl-dev \
libnftnl-dev \
automake \
make \
bash \
libstdc++-11-dev \
g++ \
git \
tree
# Step 4: Clone and install libcdada
- name: Install libcdada
run: |
cd "$ROOT/pmacct/src/external_libs/libcdada"
./autogen.sh
./configure
make -j8
sudo make install
# Step 5: Configure pmacct (generate pmacct-version.h)
- name: Configure pmacct (initial)
run: |
cd "$ROOT/pmacct"
./autogen.sh
./configure
# Step 6: Set up Rust (switch to nightly toolchain)
- name: Install Rust (nightly)
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
# Step 7: Install your custom fork of cargo-c
- name: Install cargo-c
run: |
cargo install --git https://github.com/mxyns/cargo-c cargo-c
# Step 8: Build pmacct-gauze
- name: Build pmacct-gauze
run: |
cd "$ROOT"
# install library to temporary folder because of permission issues
cargo cinstall --destdir=$PMACCT_GAUZE_BUILD_DIR -vv --package pmacct-gauze-lib
# copy library manually to /usr/local/[include/lib]
sudo cp -r $PMACCT_GAUZE_BUILD_DIR/* /
# update library cache
sudo ldconfig
- name: Upload generated artifact
uses: actions/upload-artifact@v4
id: upload-generated-artifact
with:
name: build-output
path: ${{ env.PMACCT_GAUZE_BUILD_DIR }} # Path to build artifact
# Step 9: Clean up the pmacct repository (remove libcdada)
- name: Clean up pmacct repository
run: |
cd "$ROOT/pmacct"
rm -rf src/external_libs/libcdada
# Step 10: Configure and build pmacct with pmacct-gauze enabled
- name: Build pmacct with pmacct-gauze
run: |
cd "$ROOT/pmacct"
./configure --enable-pmacct-gauze
sudo make -j8 install
# Step 11: Check Rust code formatting with rustfmt
- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
# Step 12: Run clippy to check for lints
- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --tests --all-targets --all-features -- --deny warnings
# Step 13: Check that document
- name: Generate documentation
uses: actions-rs/cargo@v1
with:
command: doc
args: --workspace --all-features
# Step 14: Run tests
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-features