linting. test refactoring. initial ci
This commit is contained in:
parent
3761c62f31
commit
776d594d34
|
@ -0,0 +1,7 @@
|
|||
before_script:
|
||||
- docker info
|
||||
|
||||
test:
|
||||
script:
|
||||
- make lint
|
||||
- make test
|
|
@ -1,16 +1,16 @@
|
|||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQIzBAABCgAdFiEEZ1U/vaRrtxq9LgsLjkeh7DWhVR0FAl+15KAACgkQjkeh7DWh
|
||||
VR1jcA//bzlmfj/rr3l/J1jbroHVLSROqIi/HtK0b6hUccVkk7cwczbaDOvHIBva
|
||||
aqiZzgRSvklVzxXFBdEtcJXV1DhWOYv+jokiyacPbnlcspoSqPX4GpH88ARKWo+p
|
||||
0T4ASS0aEvvALebtjVIoQuVLIQECqSqmuupnCsmALf62TXucU5a/Nzk/yGJxpdN/
|
||||
O12DTDU8ey4rG80Ycn6l+yuWi85JKcrAy9VIUq8b+1rV+1jRpcYJONNirIkZBUhs
|
||||
Txipc4WxEyZ9Njwb9J6lK1LyilZ4cABjW/cpVFFh4EtWUisnkH4qNQkmw0evbAGW
|
||||
gLrhrSMrkXxYOJQqtFKsKPYsF0hjDFdnSImbkD12Nm2TUetkdueLfKmDi3jDgeNY
|
||||
lJRUgbgjnkNWJ28ukdF7f4F6Z+ECkk5NCjyqmQcsX1T4HLXLrwUbTA/I3y7bG7KN
|
||||
0x97ILMXvcm2wzVROEOpqRoUxRgYUbwg3Bj8OPYshHJqnL3SH17Va+ACLfUxfcrC
|
||||
FtkM2EWkvKT5M+HFSHdeFj5RcV4JqYsFLdAdCH+d4hFvDdW3qe2oObUUd2ArAbw5
|
||||
e9XMnc86PS5tczH/CU/+n8heLIHjT6CvlkrLowQLPBWi8t58qtEk6qnWnb2iuEeD
|
||||
VlEYwIZpVwybdt1q6yxMyYettltIfcQFzgF53WXYoQUgGliqneI=
|
||||
=QAAB
|
||||
iQIzBAABCgAdFiEEZ1U/vaRrtxq9LgsLjkeh7DWhVR0FAl+25jgACgkQjkeh7DWh
|
||||
VR2qOA//fFUsl8qE3L5+5VpUX2eIJ9+fdzo+4cSgRojwZOWt4QbjfcWYGRIotyqF
|
||||
QkX2nyU1vesApQfDSDsvnC7qZq2Rm/0CXYr3+QXZ1tMT030oQYLkxG+gNQjVYqWU
|
||||
o3jPkGjZg7u8DzGngp33wgsJ6l5bP16HbIxAdslAwtccq2daq8pU9w238H8dBcyx
|
||||
WWzW7PrYae/LKAu7lMKpTEohmQ9RbXqPDoGaMks+FqZaOZvRhvTyiYFkyTMasVQM
|
||||
7gf9P5mOMyGX7GvCzkdkEUUuT1T9IcJNa2vDZP5Thyr+t+W5ABWy+uvS1G5YDBGX
|
||||
GAPAUQ2a9CpuOGwSsxlrwiXcXuPly2FqspIewAwB/jCyRcrpUHEAK4a/WiNyjl0X
|
||||
oBRskNSVKFm7K33eDQC7yMOYHraIsu8/swuaE+7joitmhQGlxXq6+fQ53sF6N8L6
|
||||
YOQH5sHvrf9RO+sDsctYEBzBCUV2MZgdoVRyOhOLyeyqMUsQ1rnCPQeqU6GCHd9m
|
||||
yrmECNaZ7fKhh37mihmBNjJzsefkXHWFgaDRIOe8MqOxQNFWjFUYl/hF4ek9bd3b
|
||||
2j6LfZ/OwrJvtywYgxPvaBc/uWG8X+2TBgxXG0tvbybIHMa9nnFQoV2ykuF7ET+Z
|
||||
4YHJkppqy7pAPwzuNkPI4/GZavABCqWzCaty5ZVMnoUpnd6nGec=
|
||||
=/hRR
|
||||
-----END PGP SIGNATURE-----
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
64263feac7b00952e9ec3b6c1fd11316faa58ff673c6bd085fac9f6f8d8389f6 .gitignore
|
||||
71be2fa2aadd9c8f77355ed17e4e246ca07d38e0e9d1f4324181c89695e82eb4 Makefile
|
||||
66a3b8bfb76f689fc4ab7bd95907b29c17c704c075c00c6cc6382e424dccd6bb .gitlab-ci.yml
|
||||
d26196a972cda50b2ce735fcce3f64fa2634f85822a18f07cd7ab42aa24bec0e Makefile
|
||||
f19d267e4aa6bf82d5416891697a2a81a574efdddecf5c54e3a8a77c207013fa README.md
|
||||
bf3492ca7625d9ac199678cf2828253e5968a87c5c444ec92e2a90ed1cbbac49 sig
|
||||
f2277f49854ad048ab66f890c01d43476aada9ee2aca7a688d4ea9fd6c0f8d2a test/Dockerfile
|
||||
ede387dce19cb471142b0bd914d4f7f99af26624080b92cb18328ece2cdfb191 test/test.bats
|
||||
c9c68b5bd5c4a62818d36731eb5a0c359474837e0e4cfe19d6ac48d15d920002 test/test_helper.bash
|
||||
b8fe3398ecd3992d190fa5f0c475a8ae424c4500407cd5b8e568b048d4844b3f sig
|
||||
655df07f3827e7055d0c6aa21a0a4907957a34a2b8a1e9131225c537e448e2e3 test/Dockerfile
|
||||
55250be3c8f25dcbe68a73e8de8c8a94d8ceb0354c7f955519373d9c963903dd test/test.bats
|
||||
c95e072f0917531257c069516fc1bf08fd98e5c5f3958f5353a219cb5b70fd38 test/test_helper.bash
|
||||
|
|
15
Makefile
15
Makefile
|
@ -1,4 +1,4 @@
|
|||
.PHONY:
|
||||
.PHONY: test
|
||||
test: test-image
|
||||
docker run \
|
||||
--rm \
|
||||
|
@ -7,6 +7,15 @@ test: test-image
|
|||
local/sig-test \
|
||||
bats sig/test/test.bats
|
||||
|
||||
.PHONY: lint
|
||||
lint: test-image
|
||||
docker run \
|
||||
--rm \
|
||||
--interactive \
|
||||
--volume $(PWD)/:/home/test/sig \
|
||||
local/sig-test \
|
||||
shellcheck sig/sig
|
||||
|
||||
.PHONY: test-image
|
||||
test-image:
|
||||
docker build \
|
||||
|
@ -14,8 +23,8 @@ test-image:
|
|||
--file $(PWD)/test/Dockerfile \
|
||||
$(PWD)
|
||||
|
||||
.PHONY:
|
||||
test-shell: test-shell
|
||||
.PHONY: test-shell
|
||||
test-shell: test-image
|
||||
docker run \
|
||||
--rm \
|
||||
--interactive \
|
||||
|
|
2
sig
2
sig
|
@ -227,7 +227,7 @@ verify_detached() {
|
|||
|
||||
for sig_filename in "${filename%.*}".*.asc; do
|
||||
gpg --verify "${sig_filename}" "${filename}" >/dev/null 2>&1 || {
|
||||
echo "Invalid signature: ${sig_filename}";
|
||||
echo "Invalid detached signature: ${sig_filename}";
|
||||
exit 1;
|
||||
}
|
||||
file_fp=$( get_file_fp "${sig_filename}" )
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
FROM debian:buster
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --force-yes bats git gnupg openssl && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
apt-get install -y --force-yes sudo bats git gnupg openssl shellcheck
|
||||
|
||||
RUN useradd -m test
|
||||
RUN useradd -m test -G sudo -s /bin/bash
|
||||
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
||||
|
||||
USER test
|
||||
|
||||
|
|
|
@ -19,38 +19,23 @@ load test_helper
|
|||
}
|
||||
|
||||
@test "Outputs advice to install missing openssl" {
|
||||
mask_command openssl
|
||||
sudo rm /usr/bin/openssl
|
||||
run sig version
|
||||
echo "${output}" | grep "apt install openssl"
|
||||
}
|
||||
|
||||
@test "Outputs advice to install missing gpg" {
|
||||
mask_command gpg
|
||||
sudo rm /usr/bin/gpg
|
||||
run sig version
|
||||
echo "${output}" | grep "apt install gnupg"
|
||||
}
|
||||
|
||||
@test "Outputs advice to install missing getopt" {
|
||||
mask_command getopt
|
||||
sudo rm /usr/bin/getopt
|
||||
run sig version
|
||||
echo "${output}" | grep "apt install getopt"
|
||||
}
|
||||
|
||||
@test "Can generate manifest for folder with git installed" {
|
||||
echo "test string" > somefile
|
||||
sig manifest
|
||||
run grep 37d2046a395cbfc .sig/manifest.txt
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "Can generate manifest for folder with git not installed" {
|
||||
mask_command git
|
||||
echo "test string" > somefile
|
||||
sig manifest
|
||||
run grep 37d2046a395cbfc .sig/manifest.txt
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "Can generate manifest for git repo" {
|
||||
set_identity "user1"
|
||||
echo "test string" > somefile
|
||||
|
@ -63,3 +48,18 @@ load test_helper
|
|||
run grep 37d2046a395cbfc .sig/manifest.txt
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "Can generate manifest for folder with git not installed" {
|
||||
sudo rm /usr/bin/git
|
||||
echo "test string" > somefile
|
||||
sig manifest
|
||||
run grep 37d2046a395cbfc .sig/manifest.txt
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "Can generate manifest for folder with git installed" {
|
||||
echo "test string" > somefile
|
||||
sig manifest
|
||||
run grep 37d2046a395cbfc .sig/manifest.txt
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
setup(){
|
||||
test -f /usr/bin/git || sudo apt install --reinstall -y git
|
||||
test -f /usr/bin/getopt || sudo apt install --reinstall -y util-linux
|
||||
test -f /usr/bin/gpg || sudo apt install --reinstall -y gpg
|
||||
test -f /usr/bin/openssl || sudo apt install --reinstall -y openssl
|
||||
bin_dir=/tmp/bin
|
||||
temp_dir=$(mktemp -d -t test-XXXXXXXXXX)
|
||||
mkdir -p /tmp/bin
|
||||
|
@ -19,11 +23,3 @@ set_identity(){
|
|||
git config --global user.email "${name}@example.com"
|
||||
git config --global user.name "${name}"
|
||||
}
|
||||
|
||||
mask_command(){
|
||||
local -r command="${1?}"
|
||||
echo "echo >&2 \"bash: ${command}: command not found\" && exit 127" \
|
||||
> "${command}"
|
||||
chmod +x "${command}"
|
||||
export PATH="$PWD:$PATH" "${command}"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue