Skip to content

Commit 84f57b2

Browse files
committed
GitHub actions: add workflows for build and packages
1 parent 9b4b2ea commit 84f57b2

File tree

2 files changed

+227
-0
lines changed

2 files changed

+227
-0
lines changed

.github/workflows/main.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build and tests
2+
3+
on:
4+
# Ignore changes in extra plugins (as they are not tested here)
5+
push:
6+
paths-ignore:
7+
- 'extra_plugins/**'
8+
pull_request:
9+
paths-ignore:
10+
- 'extra_plugins/**'
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
image: ['ubuntu:18.04', 'ubuntu:19.04', 'ubuntu:20.04', 'debian:stretch', 'debian:buster', 'debian:bullseye', 'centos:7', 'centos:8', 'fedora:29', 'fedora:30', 'fedora:31']
19+
20+
name: Build on ${{ matrix.image }}
21+
container: ${{ matrix.image }}
22+
steps:
23+
- uses: actions/checkout@v1
24+
25+
# Dependencies ---------------------------------------------------------------------------
26+
- name: Install dependencies for libfds and IPFIXcol2 (Ubuntu/Debian)
27+
if: startsWith(matrix.image, 'ubuntu') || startsWith(matrix.image, 'debian')
28+
run: |
29+
apt-get update
30+
apt-get -y install git gcc g++ cmake make libxml2-dev liblz4-dev libzstd-dev
31+
apt-get -y install python3-docutils zlib1g-dev pkg-config
32+
- name: Install dependencies for libfds and IPFIXcol2 (CentOS)
33+
if: startsWith(matrix.image, 'centos')
34+
run: |
35+
yum -y install epel-release
36+
yum -y install git gcc gcc-c++ cmake make libxml2-devel lz4-devel libzstd-devel
37+
yum -y install zlib-devel pkgconfig
38+
yum -y install python3-docutils || yum -y install python-docutils
39+
- name: Install depedencies for libfds and IPFIXcol2 (Fedora)
40+
if: startsWith(matrix.image, 'fedora')
41+
run: |
42+
dnf -y install git gcc gcc-c++ cmake make libxml2-devel lz4-devel libzstd-devel
43+
dnf -y install python3-docutils zlib-devel pkgconfig
44+
45+
# Build libfds library ------------------------------------------------------------------
46+
# Note: Master against master branch. Otherwise against debug branch.
47+
- name: Checkout libfds library - master branch
48+
if: github.ref == 'refs/heads/master'
49+
run: git clone --branch master https://github.com/CESNET/libfds.git libfds_build
50+
- name: Checkout libfds library - devel branch
51+
if: github.ref != 'refs/heads/master'
52+
run: git clone --branch devel https://github.com/CESNET/libfds.git libfds_build
53+
- name: Build and install libfds library
54+
working-directory: libfds_build
55+
run: |
56+
mkdir build && cd build
57+
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
58+
make && make install
59+
60+
# Build and test IPFIXcol2 ---------------------------------------------------------------
61+
- name: Build and install IPFIXcol2
62+
run: |
63+
mkdir build && cd build
64+
cmake .. -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=$TESTS
65+
make && make install
66+
env:
67+
TESTS: ${{ startsWith(matrix.image, 'centos:7') != true }}
68+
- name: Run tests
69+
if: startsWith(matrix.image, 'centos:7') != true
70+
run: cd build && make test
71+
- name: Try to run IPFIXcol2
72+
run: |
73+
ipfixcol2 -V
74+
ipfixcol2 -h
75+
ipfixcol2 -L -v

.github/workflows/packages.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Build RPM/DEB packages
2+
3+
on:
4+
# Ignore changes in extra plugins (as they are not tested here)
5+
push:
6+
paths-ignore:
7+
- 'extra_plugins/**'
8+
pull_request:
9+
paths-ignore:
10+
- 'extra_plugins/**'
11+
12+
jobs:
13+
deb:
14+
# Try to build DEB packages
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
image: ['ubuntu:18.04', 'ubuntu:19.04', 'ubuntu:20.04', 'debian:stretch', 'debian:buster', 'debian:bullseye']
20+
21+
name: Build DEBs on ${{ matrix.image }}
22+
container: ${{ matrix.image }}
23+
24+
steps:
25+
- uses: actions/checkout@v1
26+
- name: Define global variables
27+
run: echo "::set-output name=zip_file::libfds-${IMAGE//:/}-$GITHUB_SHA.zip"
28+
shell: bash
29+
env:
30+
IMAGE: ${{ matrix.image }}
31+
id: vars
32+
33+
# Dependencies ---------------------------------------------------------------------------
34+
- name: Install dependencies for libfds and IPFIXcol2 (Ubuntu/Debian)
35+
run: |
36+
apt-get update
37+
apt-get -y install git gcc g++ cmake make libxml2-dev liblz4-dev libzstd-dev
38+
apt-get -y install python3-docutils zlib1g-dev pkg-config
39+
apt-get -y install debhelper devscripts build-essential fakeroot zip
40+
41+
# Build LIBFDS DEB package ---------------------------------------------------------------
42+
- name: Checkout libfds library - master branch
43+
if: github.ref == 'refs/heads/master'
44+
run: git clone --branch master https://github.com/CESNET/libfds.git build/libfds_repo
45+
- name: Checkout libfds library - devel branch
46+
if: github.ref != 'refs/heads/master'
47+
run: git clone --branch devel https://github.com/CESNET/libfds.git build/libfds_repo
48+
- name: Build DEBs of libfds library and install them
49+
working-directory: 'build/libfds_repo'
50+
run: |
51+
mkdir build && cd build
52+
cmake .. -DPACKAGE_BUILDER_DEB=On -DCPACK_PACKAGE_CONTACT="GitHub actions <[email protected]>"
53+
make deb
54+
apt -y install ./pkg/deb/debbuild/libfds*.deb
55+
56+
# Build IPFIXcol2 DEB package ------------------------------------------------------------
57+
- name: Build IPFIXcol2 DEBs and install them
58+
run: |
59+
cd build
60+
cmake .. -DPACKAGE_BUILDER_DEB=On -DCPACK_PACKAGE_CONTACT="GitHub actions <[email protected]>"
61+
make deb
62+
apt -y install ./pkg/deb/debbuild/*.deb
63+
- name: Try to run IPFIXcol2
64+
run: |
65+
ipfixcol2 -V
66+
ipfixcol2 -h
67+
ipfixcol2 -L
68+
- name: Pack IPFIXcol2 DEB packages
69+
working-directory: 'build/pkg/deb/debbuild/'
70+
run: zip "$GITHUB_WORKSPACE/$ZIP_FILE" *.deb *.ddeb *.tar.gz *.dsc
71+
env:
72+
ZIP_FILE: ${{ steps.vars.outputs.zip_file }}
73+
- name: Archive DEB packages
74+
if: github.event_name == 'push'
75+
uses: actions/upload-artifact@v1
76+
with:
77+
name: ${{ steps.vars.outputs.zip_file }}
78+
path: ${{ steps.vars.outputs.zip_file }}
79+
80+
rpm:
81+
# Try to build RPM packages
82+
runs-on: ubuntu-latest
83+
strategy:
84+
fail-fast: false
85+
matrix:
86+
image: ['centos:7', 'centos:8', 'fedora:29', 'fedora:30', 'fedora:31']
87+
88+
name: Build RPMs on ${{ matrix.image }}
89+
container: ${{ matrix.image }}
90+
91+
steps:
92+
- uses: actions/checkout@v1
93+
- name: Prepare environment and variables
94+
run: |
95+
echo "::set-output name=zip_file::libfds-${IMAGE//:/}-$GITHUB_SHA.zip"
96+
mkdir -p build/libfds_repo
97+
env:
98+
IMAGE: ${{ matrix.image }}
99+
id: vars
100+
101+
# Dependencies ---------------------------------------------------------------------------
102+
- name: Install dependencies for libfds and IPFIXcol2 (CentOS)
103+
if: startsWith(matrix.image, 'centos')
104+
run: |
105+
yum -y install epel-release
106+
yum -y install git gcc gcc-c++ cmake make libxml2-devel lz4-devel libzstd-devel
107+
yum -y install zlib-devel pkgconfig rpm-build
108+
yum -y install python3-docutils || yum -y install python-docutils
109+
- name: Install depedencies for libfds and IPFIXcol2 (Fedora)
110+
if: startsWith(matrix.image, 'fedora')
111+
run: |
112+
dnf -y install git gcc gcc-c++ cmake make libxml2-devel lz4-devel libzstd-devel
113+
dnf -y install python3-docutils zlib-devel pkgconfig rpm-build
114+
115+
# Build LIBFDS RPM package ---------------------------------------------------------------
116+
- name: Checkout libfds library - master branch
117+
if: github.ref == 'refs/heads/master'
118+
run: git clone --branch master https://github.com/CESNET/libfds.git build/libfds_repo
119+
- name: Checkout libfds library - devel branch
120+
if: github.ref != 'refs/heads/master'
121+
run: git clone --branch devel https://github.com/CESNET/libfds.git build/libfds_repo
122+
- name: Build RPMs of libfds library and install it
123+
working-directory: 'build/libfds_repo'
124+
run: |
125+
mkdir build && cd build
126+
cmake .. -DPACKAGE_BUILDER_RPM=On -DCPACK_PACKAGE_CONTACT="GitHub actions <[email protected]>"
127+
make rpm
128+
yum -y install pkg/rpm/rpmbuild/RPMS/*/libfds-*.rpm
129+
130+
# Build IPFIXcol2 RPM package ------------------------------------------------------------
131+
- name: Build IPFIXcol2 RPMs and install them
132+
run: |
133+
cd build
134+
cmake .. -DPACKAGE_BUILDER_RPM=On -DCPACK_PACKAGE_CONTACT="GitHub actions <[email protected]>"
135+
make rpm
136+
yum -y install pkg/rpm/rpmbuild/RPMS/*/ipfixcol2-*.rpm
137+
- name: Try to run IPFIXcol2
138+
run: |
139+
ipfixcol2 -V
140+
ipfixcol2 -h
141+
ipfixcol2 -L -v
142+
- name: Pack IPFIXcol2 RPM packages
143+
working-directory: 'build/pkg/rpm/rpmbuild'
144+
run: zip -r "$GITHUB_WORKSPACE/$ZIP_FILE" RPMS SRPMS
145+
env:
146+
ZIP_FILE: ${{ steps.vars.outputs.zip_file }}
147+
- name: Archive RPM packages
148+
if: github.event_name == 'push'
149+
uses: actions/upload-artifact@v1
150+
with:
151+
name: ${{ steps.vars.outputs.zip_file }}
152+
path: ${{ steps.vars.outputs.zip_file }}

0 commit comments

Comments
 (0)