1
0
Fork 0
mirror of https://github.com/pavel-odintsov/fastnetmon synced 2024-05-06 00:26:21 +02:00
fastnetmon-rewritten/.circleci/config.yml

316 lines
14 KiB
YAML

version: 2.1
parameters:
fastnetmon_build_version:
type: string
default: "1.2.2"
jobs:
build_debian_upstream_package:
machine:
image: ubuntu-2004:current
resource_class: large
parameters:
debian_codename:
type: string
steps:
- run:
name: Create folder to share data between host and Docker container with relaxed permissions to allow use of save / restore cache logic
command: sudo mkdir /data; sudo chmod 777 /data
- run:
name: Docker with priviledged mode to run chroot inside and we use tail -f to keep container running
command: sudo docker run -d -v /sys/fs/cgroup/:/sys/fs/cgroup:ro -v /data:/data:rw --privileged --cap-add SYS_ADMIN --name linux_priviledged_container debian:bullseye tail -f /dev/null
- run: sudo docker exec -it linux_priviledged_container apt-get update; true
- run: sudo docker exec -it linux_priviledged_container apt install -y dpkg-dev git pbuilder
- run: sudo docker exec -it linux_priviledged_container git clone https://github.com/pavel-odintsov/fastnetmon
- run: sudo docker exec -it linux_priviledged_container git clone https://salsa.debian.org/debian/fastnetmon.git fastnetmon-debian-salsa
- run: sudo docker exec -it linux_priviledged_container tar -czf fastnetmon_$(sudo docker exec -it linux_priviledged_container head -n 1 fastnetmon-debian-salsa/debian/changelog|awk '{print $2}'|sed 's/[()]//g' | sed -E 's/(\-[0-9]+)?$//').orig.tar.gz fastnetmon
- run: sudo docker exec -it linux_priviledged_container ls -la
- run: sudo docker exec -it linux_priviledged_container bash -c "cd fastnetmon && rm -rf debian && cp -a ../fastnetmon-debian-salsa/debian/ . && dpkg-buildpackage -S -sa -d"
- run:
name: List produced source files
command: sudo docker exec -it linux_priviledged_container ls -la
- run:
name: Show content of data folder and permissions for it
command: ls -la /data
- restore_cache:
keys:
- "{{ .Environment.CIRCLE_JOB }}_debian_base_image"
- run:
name: Check that we have anything in data folder on VM
command: ls -la /data
- run:
name: "Run pbuilder run Docker if we have no image in place"
command: "if [ ! -f /data/debian_base.tgz ]; then sudo docker exec -it linux_priviledged_container pbuilder --create --basetgz /data/debian_base.tgz --distribution << parameters.debian_codename >>; else true; fi"
- save_cache:
key: "{{ .Environment.CIRCLE_JOB }}_debian_base_image"
paths:
- /data/debian_base.tgz
- run: ls -la /data
- run: sudo docker exec -it linux_priviledged_container pbuilder --build --basetgz /data/debian_base.tgz --debbuildopts "-sa" /fastnetmon_$(sudo docker exec -it linux_priviledged_container head -n 1 fastnetmon-debian-salsa/debian/changelog|awk '{print $2}'|sed 's/[()]//g').dsc
build_docker:
machine:
image: ubuntu-2004:current
steps:
- checkout
- run: docker build -t ghcr.io/pavel-odintsov/fastnetmon-community:1.2.0 -t ghcr.io/pavel-odintsov/fastnetmon-community:latest - < src/Dockerfile
- run: sudo docker images
- run: echo $CR_PAT | sudo docker login ghcr.io -u pavel-odintsov --password-stdin
- run: sudo docker push ghcr.io/pavel-odintsov/fastnetmon-community:1.2.0
- run: sudo docker push ghcr.io/pavel-odintsov/fastnetmon-community:latest
build_fedora_upstream:
parameters:
docker_image:
type: string
docker:
- image: << parameters.docker_image >>
resource_class: large
steps:
- checkout
- run: dnf install -y rpm-build rpmdevtools dnf-plugins-core
- run:
name: Install build dependencies
command: dnf builddep -y src/fastnetmon_fedora.spec
- run: mkdir -p ~/rpmbuild/SPECS
- run: cp src/fastnetmon_fedora.spec ~/rpmbuild/SPECS
- run:
name: Download source
command: cd ~/rpmbuild && spectool -g -R SPECS/fastnetmon_fedora.spec
- run:
name: Build RPM
command: cd ~/rpmbuild/SPECS && rpmbuild -bb fastnetmon_fedora.spec
- store_artifacts:
path: /root/rpmbuild/RPMS/x86_64/fastnetmon-1.2.2-1.fc35.x86_64.rpm
- store_artifacts:
path: /root/rpmbuild/RPMS/x86_64/fastnetmon-debugsource-1.2.2-1.fc35.x86_64.rpm
- store_artifacts:
path: /root/rpmbuild/RPMS/x86_64/fastnetmon-debuginfo-1.2.2-1.fc35.x86_64.rpm
build_ubuntu:
parameters:
docker_image:
type: string
ubuntu_version:
type: string
docker:
- image: << parameters.docker_image >>
resource_class: large
steps:
- checkout
- run: apt-get update; true
- run: apt-get install -y perl wget python3-pip
- run: pip3 install s3cmd
- run:
name: install_required_packages
no_output_timeout: 20m
command: perl src/fastnetmon_build.pl --install_dependency_packages_only
- restore_cache:
keys:
- "{{ .Environment.CIRCLE_JOB }}_dependencies_31_10_2020"
- restore_cache:
keys:
- "{{ .Environment.CIRCLE_JOB }}_gcc_25_10_2020"
- run:
name: install_gcc
no_output_timeout: 120m
command: perl src/fastnetmon_build.pl --build_gcc_only
- save_cache:
key: "{{ .Environment.CIRCLE_JOB }}_gcc_25_10_2020"
paths:
- /opt/gcc930
- run:
name: install_dependencies
no_output_timeout: 180m
command: perl src/fastnetmon_build.pl --build_dependencies_only
- run:
name: collect_debug
command: cat /tmp/fastnetmon_install.log
when: on_fail
- save_cache:
key: "{{ .Environment.CIRCLE_JOB }}_dependencies_31_10_2020"
paths:
- /opt
- run: perl src/fastnetmon_build.pl --use-git-master --build_fastnetmon_only
- run: perl src/scripts/build_libary_bundle.pl /opt/fastnetmon_libraries_bundle.tar.gz
- store_artifacts:
path: /opt/fastnetmon_libraries_bundle.tar.gz
- store_artifacts:
path: /tmp/fastnetmon_install.log
- run: src/scripts/build_any_package.pl deb /opt/fastnetmon_libraries_bundle.tar.gz << pipeline.parameters.fastnetmon_build_version >> ubuntu << parameters.ubuntu_version >>
- store_artifacts:
path: /tmp/fastnetmon_<< pipeline.parameters.fastnetmon_build_version >>_amd64.deb
- run: s3cmd --disable-multipart --host=storage.googleapis.com --host-bucket="%(bucket).storage.googleapis.com" put /tmp/fastnetmon_<< pipeline.parameters.fastnetmon_build_version >>_amd64.deb s3://fastnetmon_community_packages/<< pipeline.parameters.fastnetmon_build_version >>/ubuntu/<< parameters.ubuntu_version >>/fastnetmon_<< pipeline.parameters.fastnetmon_build_version >>_amd64.deb
- run: cp src/fastnetmon.conf /etc/fastnetmon.conf
- run: ldd /opt/fastnetmon/fastnetmon
- run: ldd /opt/fastnetmon/fastnetmon_client
- run: ldd /opt/fastnetmon/fastnetmon_api_client
- run: /opt/fastnetmon/fastnetmon --configuration_check
build_debian:
parameters:
docker_image:
type: string
debian_version:
type: string
docker:
- image: << parameters.docker_image >>
resource_class: large
steps:
- checkout
- run: apt-get update; true
- run: apt-get install -y perl wget python3-pip
- run: pip3 install s3cmd
- run:
name: install_required_packages
no_output_timeout: 20m
command: perl src/fastnetmon_build.pl --install_dependency_packages_only
- restore_cache:
keys:
- "{{ .Environment.CIRCLE_JOB }}_dependencies_31_10_2020"
- restore_cache:
keys:
- "{{ .Environment.CIRCLE_JOB }}_gcc_25_10_2020"
- run:
name: install_gcc
no_output_timeout: 120m
command: perl src/fastnetmon_build.pl --build_gcc_only
- save_cache:
key: "{{ .Environment.CIRCLE_JOB }}_gcc_25_10_2020"
paths:
- /opt/gcc930
- run:
name: install_dependencies
no_output_timeout: 180m
command: perl src/fastnetmon_build.pl --build_dependencies_only
- run:
name: collect_debug
command: cat /tmp/fastnetmon_install.log
when: on_fail
- save_cache:
key: "{{ .Environment.CIRCLE_JOB }}_dependencies_31_10_2020"
paths:
- /opt
- run: perl src/fastnetmon_build.pl --use-git-master --build_fastnetmon_only
- run: perl src/scripts/build_libary_bundle.pl /opt/fastnetmon_libraries_bundle.tar.gz
- store_artifacts:
path: /opt/fastnetmon_libraries_bundle.tar.gz
- store_artifacts:
path: /tmp/fastnetmon_install.log
- run: src/scripts/build_any_package.pl deb /opt/fastnetmon_libraries_bundle.tar.gz << pipeline.parameters.fastnetmon_build_version >> debian << parameters.debian_version >>
- store_artifacts:
path: /tmp/fastnetmon_<< pipeline.parameters.fastnetmon_build_version >>_amd64.deb
- run: s3cmd --disable-multipart --host=storage.googleapis.com --host-bucket="%(bucket).storage.googleapis.com" put /tmp/fastnetmon_<< pipeline.parameters.fastnetmon_build_version >>_amd64.deb s3://fastnetmon_community_packages/<< pipeline.parameters.fastnetmon_build_version >>/debian/<< parameters.debian_version >>/fastnetmon_<< pipeline.parameters.fastnetmon_build_version >>_amd64.deb
- run: cp src/fastnetmon.conf /etc/fastnetmon.conf
- run: ldd /opt/fastnetmon/fastnetmon
- run: ldd /opt/fastnetmon/fastnetmon_client
- run: ldd /opt/fastnetmon/fastnetmon_api_client
build_centos:
parameters:
docker_image:
type: string
centos_version:
type: string
docker:
- image: << parameters.docker_image >>
resource_class: large
steps:
- checkout
- run: yum install -y perl wget python3-pip perl-Archive-Tar
- run: pip3 install s3cmd
- run:
name: install_required_packages
no_output_timeout: 20m
command: perl src/fastnetmon_build.pl --install_dependency_packages_only
- restore_cache:
keys:
- "{{ .Environment.CIRCLE_JOB }}_dependencies_31_10_2020"
- restore_cache:
keys:
- "{{ .Environment.CIRCLE_JOB }}_gcc_25_10_2020"
- run:
name: install_gcc
no_output_timeout: 120m
command: perl src/fastnetmon_build.pl --build_gcc_only
- save_cache:
key: "{{ .Environment.CIRCLE_JOB }}_gcc_25_10_2020"
paths:
- /opt/gcc930
- run:
name: install_dependencies
no_output_timeout: 180m
command: perl src/fastnetmon_build.pl --build_dependencies_only
- run:
name: collect_debug
command: cat /tmp/fastnetmon_install.log
when: on_fail
- save_cache:
key: "{{ .Environment.CIRCLE_JOB }}_dependencies_31_10_2020"
paths:
- /opt
- /usr/include/linux/pf_ring.h
- store_artifacts:
path: /tmp/fastnetmon_install.log
- run: perl src/fastnetmon_build.pl --use-git-master --build_fastnetmon_only
- run: perl src/scripts/build_libary_bundle.pl /opt/fastnetmon_libraries_bundle.tar.gz
- store_artifacts:
path: /opt/fastnetmon_libraries_bundle.tar.gz
- run: src/scripts/build_any_package.pl rpm /opt/fastnetmon_libraries_bundle.tar.gz << pipeline.parameters.fastnetmon_build_version >> centos << parameters.centos_version >>
- store_artifacts:
path: /tmp/result_data/fastnetmon-<< pipeline.parameters.fastnetmon_build_version >>-1.el<< parameters.centos_version >>.x86_64.rpm
- run: s3cmd --disable-multipart --host=storage.googleapis.com --host-bucket="%(bucket).storage.googleapis.com" put /tmp/result_data/fastnetmon-<< pipeline.parameters.fastnetmon_build_version >>-1.el<< parameters.centos_version >>.x86_64.rpm s3://fastnetmon_community_packages/<< pipeline.parameters.fastnetmon_build_version >>/centos/<< parameters.centos_version >>/fastnetmon-<< pipeline.parameters.fastnetmon_build_version >>-1.el<< parameters.centos_version >>.x86_64.rpm
- run: cp src/fastnetmon.conf /etc/fastnetmon.conf
- run: ldd /opt/fastnetmon/fastnetmon
- run: ldd /opt/fastnetmon/fastnetmon_client
- run: ldd /opt/fastnetmon/fastnetmon_api_client
- run: /opt/fastnetmon/fastnetmon --configuration_check
workflows:
version: 2
all_distros:
jobs:
- build_centos:
docker_image: centos:centos7
centos_version: "7"
name: "centos7"
- build_centos:
docker_image: almalinux:8
centos_version: "8"
name: "centos8"
- build_ubuntu:
docker_image: "ubuntu:jammy"
ubuntu_version: "22.04"
name: "ubuntu2204"
- build_ubuntu:
docker_image: "ubuntu:focal"
ubuntu_version: "20.04"
name: "ubuntu2004"
- build_ubuntu:
docker_image: "ubuntu:bionic"
ubuntu_version: "18.04"
name: "ubuntu1804"
- build_ubuntu:
docker_image: "ubuntu:xenial"
ubuntu_version: "16.04"
name: "ubuntu1604"
- build_ubuntu:
docker_image: "ubuntu:trusty"
ubuntu_version: "14.04"
name: "ubuntu1404"
- build_debian:
docker_image: "debian:stretch"
debian_version: "9"
name: "debian9"
- build_debian:
docker_image: "debian:buster"
debian_version: "10"
name: "debian10"
- build_debian:
docker_image: "debian:bullseye"
debian_version: "11"
name: "debian11"
- build_docker
- build_debian_upstream_package:
name: "Debian Sid Upstream Build"
debian_codename: "sid"
- build_debian_upstream_package:
name: "Debian Bullseye Upstream Backports Build"
debian_codename: "bullseye"
- build_fedora_upstream:
name: "Fedora 35 Upstream RPM"
docker_image: fedora:35