Skip to content

ci: formatting and misc improvements #5802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions .github/workflows/build-extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- .git-blame-ignore-revs
- .github/dependabot.yml
- .github/pull_request_template.md
- .github/workflows/build.yml
- .github/workflows/codeql-analysis.yml
- .github/workflows/profile-checks.yml
- .gitignore
Expand All @@ -34,6 +35,7 @@ on:
- .git-blame-ignore-revs
- .github/dependabot.yml
- .github/pull_request_template.md
- .github/workflows/build.yml
- .github/workflows/codeql-analysis.yml
- .github/workflows/profile-checks.yml
- .gitignore
Expand Down Expand Up @@ -65,8 +67,12 @@ jobs:
run: sudo apt-get update
- name: install dependencies
run: sudo apt-get install libapparmor-dev libselinux1-dev
- name: print env
run: ./ci/printenv.sh
- name: configure
run: CC=clang-14 ./configure --enable-fatal-warnings --enable-apparmor --enable-selinux
run: >
CC=clang-14 ./configure --enable-fatal-warnings --enable-apparmor
--enable-selinux
- name: make
run: make
- name: make install
Expand All @@ -88,8 +94,12 @@ jobs:
run: sudo apt-get update
- name: install clang-tools-14 and dependencies
run: sudo apt-get install clang-tools-14 libapparmor-dev libselinux1-dev
- name: print env
run: ./ci/printenv.sh
- name: configure
run: CC=clang-14 ./configure --enable-fatal-warnings --enable-apparmor --enable-selinux
run: >
CC=clang-14 ./configure --enable-fatal-warnings --enable-apparmor
--enable-selinux
- name: scan-build
run: NO_EXTRA_CFLAGS="yes" scan-build-14 --status-bugs make
cppcheck:
Expand All @@ -107,10 +117,13 @@ jobs:
run: sudo apt-get update
- name: install cppcheck
run: sudo apt-get install cppcheck
- run: cppcheck --version
- name: cppcheck
run: cppcheck -q --force --error-exitcode=1 --enable=warning,performance -i src/firejail/checkcfg.c -i src/firejail/main.c .
# new cppcheck version currently chokes on checkcfg.c and main.c, therefore scan all files also
# with older cppcheck version from ubuntu 20.04.
run: >
cppcheck -q --force --error-exitcode=1 --enable=warning,performance
-i src/firejail/checkcfg.c -i src/firejail/main.c .
# new cppcheck version currently chokes on checkcfg.c and main.c, therefore
# scan all files also with older cppcheck version from ubuntu 20.04.
cppcheck_old:
runs-on: ubuntu-20.04
steps:
Expand All @@ -126,6 +139,7 @@ jobs:
run: sudo apt-get update
- name: install cppcheck
run: sudo apt-get install cppcheck
- run: cppcheck --version
- name: cppcheck
run: cppcheck -q --force --error-exitcode=1 --enable=warning,performance .
codespell:
Expand All @@ -143,5 +157,6 @@ jobs:
run: sudo apt-get update
- name: install dependencies
run: sudo apt-get install codespell
- run: codespell --version
- name: codespell
run: make codespell
63 changes: 29 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- .git-blame-ignore-revs
- .github/dependabot.yml
- .github/pull_request_template.md
- .github/workflows/build-extra.yml
- .github/workflows/codeql-analysis.yml
- .github/workflows/profile-checks.yml
- .gitignore
Expand All @@ -25,6 +26,7 @@ on:
- .git-blame-ignore-revs
- .github/dependabot.yml
- .github/pull_request_template.md
- .github/workflows/build-extra.yml
- .github/workflows/codeql-analysis.yml
- .github/workflows/profile-checks.yml
- .gitignore
Expand All @@ -42,6 +44,8 @@ permissions: # added using https://github.com/step-security/secure-workflows
jobs:
build_and_test:
runs-on: ubuntu-22.04
env:
SHELL: /bin/bash
steps:
- name: Harden Runner
uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3
Expand All @@ -60,44 +64,35 @@ jobs:
- name: update package information
run: sudo apt-get update
- name: install dependencies
run: sudo apt-get install gcc-12 libapparmor-dev libselinux1-dev expect xzdec whois bridge-utils
run: >
sudo apt-get install
gcc-12 libapparmor-dev libselinux1-dev expect xzdec whois
bridge-utils
- name: print env
run: ./ci/printenv.sh
- name: configure
run: CC=gcc-12 ./configure --prefix=/usr --enable-fatal-warnings --enable-analyzer --enable-apparmor --enable-selinux
run: >
CC=gcc-12 ./configure --prefix=/usr --enable-fatal-warnings
--enable-analyzer --enable-apparmor --enable-selinux
- name: make
run: make
- name: make install
run: sudo make install
- name: print firejail version
run: command -V firejail && firejail --version
- name: lab setup
run: SHELL=/bin/bash make lab-setup
- name: run seccomp extra tests
run: SHELL=/bin/bash make test-seccomp-extra
- name: run firecfg tests
run: SHELL=/bin/bash make test-firecfg
- name: run capabilities tests
run: SHELL=/bin/bash make test-capabilities
- name: run apparmor tests
run: SHELL=/bin/bash make test-apparmor
- name: run appimage tests
run: SHELL=/bin/bash make test-appimage
- name: run chroot tests
run: SHELL=/bin/bash make test-chroot
- name: run sysutils tests
run: SHELL=/bin/bash make test-sysutils
- name: run private-etc tests
run: SHELL=/bin/bash make test-private-etc
- name: run profile tests
run: SHELL=/bin/bash make test-profiles
- name: run fcopy tests
run: SHELL=/bin/bash make test-fcopy
- name: run fnetfilter tests
run: SHELL=/bin/bash make test-fnetfilter
- name: run fs tests
run: SHELL=/bin/bash make test-fs
- name: run utils tests
run: SHELL=/bin/bash make test-utils
- name: run environment tests
run: SHELL=/bin/bash make test-environment
- name: run network tests
run: SHELL=/bin/bash make test-network
- run: make lab-setup
- run: make test-seccomp-extra
- run: make test-firecfg
- run: make test-capabilities
- run: make test-apparmor
- run: make test-appimage
- run: make test-chroot
- run: make test-sysutils
- run: make test-private-etc
- run: make test-profiles
- run: make test-fcopy
- run: make test-fnetfilter
- run: make test-fs
- run: make test-utils
- run: make test-environment
- run: make test-network
7 changes: 7 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ on:
- .git-blame-ignore-revs
- .github/dependabot.yml
- .github/pull_request_template.md
- .github/workflows/build-extra.yml
- .github/workflows/build.yml
- .github/workflows/profile-checks.yml
- .gitignore
- .gitlab-ci.yml
Expand All @@ -39,6 +41,8 @@ on:
- .git-blame-ignore-revs
- .github/dependabot.yml
- .github/pull_request_template.md
- .github/workflows/build-extra.yml
- .github/workflows/build.yml
- .github/workflows/profile-checks.yml
- .gitignore
- .gitlab-ci.yml
Expand Down Expand Up @@ -87,6 +91,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab

- name: print env
run: ./ci/printenv.sh

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@b2c19fb9a2a485599ccf4ed5d65527d94bc57226
Expand Down
22 changes: 17 additions & 5 deletions .github/workflows/profile-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,24 @@ jobs:
github.com:443

- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- name: print env
run: ./ci/printenv.sh
- run: python3 --version

# - name: sort.py
# run: ./ci/check/profiles/sort.py etc/inc/*.inc etc/{profile-a-l,profile-m-z}/*.profile
# run: >
# ./ci/check/profiles/sort.py
# etc/inc/*.inc etc/{profile-a-l,profile-m-z}/*.profile
# Currently broken (see #5610)
# - name: private-etc-always-required.sh
# run: ./ci/check/profiles/private-etc-always-required.sh etc/inc/*.inc etc/{profile-a-l,profile-m-z}/*.profile
# - name: private-etc-always-required.sh
# run: >
# ./ci/check/profiles/private-etc-always-required.sh
# etc/inc/*.inc etc/{profile-a-l,profile-m-z}/*.profile
- name: sort-disable-programs.sh
run: ./ci/check/profiles/sort-disable-programs.sh etc/inc/disable-programs.inc
run: >
./ci/check/profiles/sort-disable-programs.sh
etc/inc/disable-programs.inc
- name: sort-firecfg.config.sh
run: ./ci/check/profiles/sort-firecfg.config.sh src/firecfg/firecfg.config
run: >
./ci/check/profiles/sort-firecfg.config.sh
src/firecfg/firecfg.config
55 changes: 43 additions & 12 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@
# and fedora:latest for new setups
# 3. Alpine for installing directly from source
# Also builds apparmor package for Ubuntu LTS

build_ubuntu_package:
image: ubuntu:rolling
script:
- apt-get update -qq
- DEBIAN_FRONTEND=noninteractive apt-get install -y -qq build-essential lintian libapparmor-dev pkg-config python3 gawk
- >
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq
build-essential lintian libapparmor-dev pkg-config python3 gawk
- ./ci/printenv.sh
- ./configure
- make deb
- dpkg -i firejail*.deb
- command -V firejail && firejail --version
# - python3 --version
# - python3 contrib/sort.py etc/profile-*/*.profile etc/inc/*.inc

build_debian_package:
image: debian:stretch
script:
- apt-get update -qq
- apt-get install -y -qq build-essential lintian libapparmor-dev pkg-config gawk
- >
apt-get install -y -qq
build-essential lintian libapparmor-dev pkg-config gawk
- ./ci/printenv.sh
- ./configure
- make deb
- dpkg -i firejail*.deb
Expand All @@ -31,6 +39,7 @@ build_redhat_package:
script:
- dnf update -y
- dnf install -y rpm-build gcc make
- ./ci/printenv.sh
- ./configure --prefix=/usr
- make rpms
- rpm -i firejail*.rpm
Expand All @@ -41,10 +50,12 @@ build_fedora_package:
script:
- dnf update -y
- dnf install -y rpm-build gcc make
- ./ci/printenv.sh
- ./configure --prefix=/usr
- make rpms
- rpm -i firejail*.rpm
- command -V firejail && firejail --version
# - python3 --version
# - python3 contrib/sort.py etc/profile-*/*.profile etc/inc/*.inc

build_src_package:
Expand All @@ -53,17 +64,22 @@ build_src_package:
- apk update
- apk upgrade
- apk add build-base linux-headers python3 gawk
- ./ci/printenv.sh
- ./configure --prefix=/usr
- make
- make install-strip
- command -V firejail && firejail --version
# - python3 contrib/sort.py etc/*.{profile,inc}
# - python3 --version
# - python3 contrib/sort.py etc/profile-*/*.profile etc/inc/*.inc

build_no_apparmor:
image: ubuntu:latest
script:
- apt-get update -qq
- DEBIAN_FRONTEND=noninteractive apt-get install -y -qq build-essential lintian pkg-config gawk
- >
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq
build-essential lintian pkg-config gawk
- ./ci/printenv.sh
- ./configure
- make dist
- ./mkdeb.sh --disable-apparmor
Expand All @@ -77,21 +93,36 @@ debian_ci:
DEBFULLNAME: "$GITLAB_USER_NAME"
DEBEMAIL: "$GITLAB_USER_EMAIL"
before_script:
- git checkout -B ci_build $CI_COMMIT_SHA
- git checkout -B ci_build "$CI_COMMIT_SHA"
- gitlab-ci-enable-sid
- gitlab-ci-enable-experimental
- echo "deb-src http://deb.debian.org/debian sid main" >> /etc/apt/sources.list
- echo "deb-src http://deb.debian.org/debian experimental main" >> /etc/apt/sources.list
- |
cat >>/etc/apt/sources.list <<EOF
deb-src http://deb.debian.org/debian sid main
deb-src http://deb.debian.org/debian experimental main
EOF
- apt-get update
- git config user.name "$DEBFULLNAME"
- git config user.email "$DEBEMAIL"
- cd $CI_PROJECT_DIR/.. && (apt-get source --download-only -t experimental firejail || apt-get source --download-only firejail)
- cd $CI_PROJECT_DIR && tar xf ../firejail_*.debian.tar.*
- |
cd "$CI_PROJECT_DIR/.."
apt-get source --download-only -t experimental firejail ||
apt-get source --download-only firejail
- |
cd "$CI_PROJECT_DIR"
tar xf ../firejail_*.debian.tar.*
- rm -rf debian/patches/
- VERSION=$(grep ^PACKAGE_VERSION= configure | cut -d"'" -f2) && dch -v ${VERSION}-0.1~ci "Non-maintainer upload." && git archive -o ../firejail_${VERSION}.orig.tar.gz HEAD && pristine-tar commit ../firejail_${VERSION}.orig.tar.gz ci_build && git branch -m pristine-tar origin/pristine-tar
- git add debian && git commit -m "add debian/"
- export CI_COMMIT_SHA=$(git rev-parse HEAD)
- |
VERSION="$(grep ^PACKAGE_VERSION= configure | cut -d "'" -f 2)"
dch -v "${VERSION}-0.1~ci" 'Non-maintainer upload.'
git archive -o "../firejail_${VERSION}.orig.tar.gz" HEAD
pristine-tar commit "../firejail_${VERSION}.orig.tar.gz" ci_build
git branch -m pristine-tar origin/pristine-tar
- git add debian
- git commit -m 'add debian/'
- export CI_COMMIT_SHA="$(git rev-parse HEAD)"
script:
- apt-get --no-install-recommends install -y -qq gawk
- ./ci/printenv.sh
- gitlab-ci-git-buildpackage
- gitlab-ci-lintian
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ scan-build: clean
codespell: clean
codespell --ignore-regex "UE|creat|shotcut|ether" src test

.PHONY: print-env
print-env:
./ci/printenv.sh

#
# make test
#
Expand Down
25 changes: 25 additions & 0 deletions ci/printenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
# Print information that may be useful for debugging CI.

test -f /etc/os-release && . /etc/os-release

cat <<EOF
nproc: $(nproc)
kernel: $(uname -srvm)
distro: $PRETTY_NAME
sh: $(ls -l /bin/sh | sed 's|.* /bin|/bin|')
user: $(id | cut -f -2 -d ' ')

[/etc/os-release]
$(cat /etc/os-release)
EOF

if test -z "$CI_VERBOSE"; then
exit
fi

cat <<EOF

[env]
$(env | LC_ALL=C sort)
EOF