Skip to content

Commit

Permalink
Add initial github tests
Browse files Browse the repository at this point in the history
Add running and packaging tests.
Fix problems found when adding tests

Signed-off-by: Corentin Labbe <[email protected]>
  • Loading branch information
montjoie committed Oct 13, 2024
1 parent 0eead3d commit 75ff6e4
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 4 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
# yamllint disable rule:line-length
name: tests yasat

on: # yamllint disable-line rule:truthy
push:
pull_request:

jobs:
test-ubuntu:
runs-on: ubuntu-latest
name: test on ubuntu
steps:
- uses: actions/checkout@v4
- name: update pkglist
run: sudo apt-get update
- name: install some tested packages
run: sudo apt-get -y install tomcat9
- name: Run tests
run: |
make test
./tests/test.test -d
- name: Run yasat
run: |
./yasat
./yasat -1 ntp
./yasat -1 cups
./yasat -1 classique
ls -l /home/runner/.yasat//yasat.report
test-bashishms:
runs-on: ubuntu-latest
name: Check bashisms
steps:
- uses: actions/checkout@v4
- name: update pkglist
run: sudo apt-get update
- name: install checkbashisms
run: sudo apt-get -y install devscripts
- name: Run checkbashisms
run: checkbashisms yasat common plugins/*test
ubuntu-pkg:
runs-on: ubuntu-latest
name: build ubuntu package
steps:
- uses: actions/checkout@v4
- name: update pkglist
run: sudo apt-get update
- name: Install packages
run: sudo apt-get -y install devscripts gnupg debhelper-compat
- name: create orig targz
run: cd .. && tar czf yasat_0-1.orig.tar.gz yasat
- name: Run debuild
run: debuild -i -us -uc -b --lintian-opts --profile debian
- name: Run debuild help
run: debuild --help
debian-pkg:
runs-on: ubuntu-latest
name: build debian package
steps:
- uses: actions/checkout@v4
- name: update pkglist
run: sudo apt-get update
- name: Install packages
run: sudo apt-get -y install debootstrap
- name: Create a bookworm
run: sudo debootstrap bookworm /root/bookworm
- name: copy yasat source
run: sudo cp -a ../yasat /root/bookworm/
- name: Install update pkg in chroot
run: sudo chroot /root/bookworm apt-get update
- name: Install update pkg in chroot
run: sudo chroot /root/bookworm apt-get -y install devscripts gnupg debhelper-compat
- name: Generate wrapper
run: |
echo '#!/bin/sh' >> run.sh
echo 'cd /yasat' >> run.sh
echo 'debuild -i -us -uc -b' >> run.sh
chmod 755 run.sh
sudo cp run.sh /root/bookworm/
- name: Run debuild
run: sudo chroot /root/bookworm /run.sh
14 changes: 14 additions & 0 deletions common
Original file line number Diff line number Diff line change
Expand Up @@ -2455,6 +2455,20 @@ Is_installed_via_package_manager()
return 0;
fi
if [ "$LIST_PKG" = "emerge" ] ;then
if [ -z "$CACHE_EMERGE_OK" ];then
# check if we have can use portage
emerge --info 2>/dev/null >/dev/null
if [ $? -ne 0 ];then
Display --indent 2 --text "Could not work with emerge (cached)" --result EPERM --color RED
CACHE_EMERGE_OK="ko"
return 0
fi
fi
if [ "$CACHE_EMERGE_OK" = 'ko' ];then
Display --indent 2 --text "Could not work with emerge (cached)" --result EPERM --color RED
return 0
fi
CACHE_EMERGE_OK="ok"
#TODO could be better
PKGLIST="`equery -C -q l $1`"
if [ -z "$PKGLIST" ] ;then
Expand Down
2 changes: 1 addition & 1 deletion debian/compat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5
10
10 changes: 9 additions & 1 deletion plugins/apache_modules.test
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ fi
check_file "$APACHE_BIN" 2 BINARY

if [ "$LINUX_VERSION" = "Gentoo" ] ;then
. /etc/conf.d/apache2
if [ ! -r /etc/conf.d/apache2 ];then
TESTNAME='YASAT_TEST_APACHE_MODULES_READ_CONFD_APACHE Check if we can use /etc/conf.d/apache2'
Display --indent 2 --text "Cannot read /etc/conf.d/apache2" --result ERROR --color RED
else
. /etc/conf.d/apache2
if [ $? -ne 0 ];then
echo "ERROR: could not read /etc/conf.d/apache2"
fi
fi
APACHE_BIN="$APACHE_BIN $APACHE2_OPTS"
fi

Expand Down
5 changes: 5 additions & 0 deletions plugins/process.data
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ aisexec=CANBEROOT
/usr/sbin/atd=CANBEROOT
/usr/sbin/monit=CANBEROOT
/sbin/rsyslogd=CANBEROOT
/usr/bin/containerd=CANBEROOT
/usr/libexec/packagekitd=CANBEROOT
/usr/libexec/polkitd=CANBEROOT
/sbin/agetty=CANBEROOT
/usr/bin/podman=CANBEROOT

#ONLYROOT
/sbin/udevd=ONLYROOT
Expand Down
2 changes: 1 addition & 1 deletion plugins/process.test
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Title "Check running process"
if [ ! -e "${PLUGINS_REP}/process.data" ]
then
Display --indent 2 --text "process.data" --result NOTFOUND --color RED
return -1;
return 1;
fi

#TODO FreeBSD said ps: Process environment requires procfs(5)
Expand Down
2 changes: 1 addition & 1 deletion plugins/tomcat.test
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ do
then
Display --indent 2 --text "Tomcat $TOMCAT_VERSION found at $BASE_TOMCAT" --result FOUND --color GREEN

check_directory_others $BASE_TOMCAT $TMP_RESULT2 4
check_directory_others $BASE_TOMCAT $TMP_RESULT2 4 TODO

fi
if [ "$TOMCAT_MAJOR_VERSION" != "0" -a "$TOMCAT_MINOR_VERSION" != "0" ] ;then
Expand Down
8 changes: 8 additions & 0 deletions tests/test.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ QUIET=0
HIDESR=0
YASAT_ROOT=.
COL_WIDTH="`tput cols`"
# tput could fail
if [ -z "$COL_WIDTH" ];then
COL_WIDTH=79
fi
PRINT_LEVEL=0
ADVICELANG='EN'

if [ "$1" == "-d" ];then
DEBUG=1
fi

. ./common
. ./osdetection

Expand Down

0 comments on commit 75ff6e4

Please sign in to comment.