Skip to content

Commit 0204c30

Browse files
authored
Merge pull request donapieppo#24 from sshedi/workflow
Add github workflow
2 parents b739ba2 + 801315d commit 0204c30

File tree

4 files changed

+109
-23
lines changed

4 files changed

+109
-23
lines changed

.github/workflows/ci.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: libnss-ato CI
2+
3+
on: [pull_request, push, workflow_dispatch]
4+
5+
jobs:
6+
basic-sanity:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: build container
11+
working-directory: ${{ github.workspace }}
12+
run: |
13+
docker build -t libnss-ato -f ci/Dockerfile .
14+
- name: run tests in container
15+
working-directory: ${{ github.workspace }}
16+
run: |
17+
docker run --security-opt seccomp:unconfined --rm -v$(pwd):/build -w/build libnss-ato ./ci/docker-entrypoint.sh

Dockerfile

-23
This file was deleted.

ci/Dockerfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM fedora:latest
2+
3+
MAINTAINER Donapieppo <[email protected]>
4+
5+
RUN dnf install -y gcc --refresh
6+
7+
# docker build -t libnss-ato .
8+
# docker run -it -v$(pwd):/build -w/build libnss-ato /bin/bash
9+
#
10+
# and then make && make installi
11+
#
12+
# make necessary modifications to /etc/libnss-ato.conf, example
13+
# echo "t:x:1000:1000:Test User:/home/test:/bin/bash" > /etc/libnss-ato.conf
14+
#
15+
# add ato to /etc/nsswitch.conf, example:
16+
# sed -ie '/^passwd:/ s/$/ ato/' /etc/nsswitch.conf
17+
# sed -ie '/^shadow:/ s/$/ ato/' /etc/nsswitch.conf

ci/docker-entrypoint.sh

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
fini() {
6+
local retval="$?"
7+
8+
rm -rf ${destdir} \
9+
/usr/lib/libnss_ato*.so* \
10+
/etc/libnss-ato.conf
11+
12+
echo ""
13+
make clean
14+
15+
if [ $retval -eq 0 ]; then
16+
echo -e "\nAll tests PASSED\n"
17+
else
18+
echo -e "\nOne or more tests FAILED\n" 1>&2
19+
fi
20+
21+
exit "$retval"
22+
}
23+
24+
trap fini EXIT
25+
26+
echo -e "\nBuild test ...\n"
27+
make
28+
echo -e "\nBuild test PASS ...\n"
29+
30+
echo -e "\nInstall test ...\n"
31+
32+
destdir="$PWD/tmp"
33+
make install DESTDIR="${destdir}"
34+
35+
ls ${destdir}/usr/lib/libnss_ato*.so*
36+
test -s ${destdir}/etc/libnss-ato.conf
37+
test -s ${destdir}/usr/share/man/man3/libnss-ato.3
38+
39+
echo -e "\nInstall test PASS ...\n"
40+
41+
echo -e "\nFunctionality tests ..."
42+
43+
echo "Try with root user ..."
44+
./libnss_ato_test root
45+
46+
echo -e "\nTry with non existent user without enabling libnss-ato ..."
47+
48+
if ./libnss_ato_test test123; then
49+
echo "Passed with non existent user without enabling libnss-ato ..." 1>&2
50+
exit 1
51+
fi
52+
53+
echo -e "\nFailed as expected ..."
54+
55+
echo -e "\nEnable libnss-ato now ..."
56+
57+
cp ${destdir}/usr/lib/libnss_ato*.so* /usr/lib/
58+
cp ${destdir}/etc/libnss-ato.conf /etc/
59+
60+
ldconfig
61+
62+
echo "t:x:1000:1000:Test User:/home/test:/bin/bash" >> /etc/libnss-ato.conf
63+
64+
sed -ie '/^passwd:/ s/$/ ato/' /etc/nsswitch.conf
65+
sed -ie '/^shadow:/ s/$/ ato/' /etc/nsswitch.conf
66+
67+
echo -e "\nTry with non existent user after enabling libnss-ato ..."
68+
69+
if ! ./libnss_ato_test test123; then
70+
echo "Failed with non existent user after enabling libnss-ato ..." 1>&2
71+
exit 1
72+
fi
73+
74+
echo -e "\nFunctionality tests PASS ...\n"
75+
exit 0

0 commit comments

Comments
 (0)