Skip to content

Commit 4e66753

Browse files
Merge pull request #114 from newcontext-oss/feature/add_alpine_integration_tests
add integration tests for alpine linux
2 parents d3a5f38 + 9a58cce commit 4e66753

File tree

20 files changed

+242
-13
lines changed

20 files changed

+242
-13
lines changed

.Dockerfiles/alpine/latest/Dockerfile

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM alpine:latest
2+
3+
# - build tools are for: fig2dev which is needed by gnupg builds
4+
# - openssh is for scp
5+
# - tini is for PID 1
6+
# - changing alpine from 3.6 to 3.7 is for ansible 2.4,
7+
# but need to install ansible 2.3 for dependencies first
8+
# - shellcheck is not in the apk repository (xz/tar needed for shellcheck)
9+
# - bundler/rspec is not found on kitchen verify (symlink needed)
10+
11+
RUN apk add --no-cache --update \
12+
curl net-tools \
13+
openssh-server openssh \
14+
sudo bash tini \
15+
ansible git rsync xz \
16+
gcc autoconf automake g++ libffi-dev tar libxpm-dev make \
17+
autoconf automake imagemagick-dev texinfo gettext-dev libgcrypt-dev \
18+
libgpg-error-dev libassuan-dev libksba-dev npth-dev libxfont-dev \
19+
libwmf-dev libx11-dev libxt-dev libxext-dev libxml2-dev libexif-dev perl \
20+
ruby-dev ruby-bundler \
21+
&& ln -s /usr/bin/bundle /usr/local/bin/bundle \
22+
&& ln -s /usr/bin/rspec /usr/local/bin/rspec \
23+
&& sed -i -e 's/v3\.6/v3.7/g' /etc/apk/repositories \
24+
&& apk add --update-cache --upgrade ansible \
25+
&& sed -i -e 's/v3\.7/v3.6/g' /etc/apk/repositories \
26+
&& apk add --update-cache \
27+
&& curl --silent -L -o shellcheck.tar.xz https://storage.googleapis.com/shellcheck/shellcheck-latest.linux.x86_64.tar.xz \
28+
&& tar -vxf shellcheck.tar.xz \
29+
&& mv shellcheck-latest/shellcheck /usr/local/bin/ \
30+
&& sudo mkdir -p /usr/local/src/ \
31+
&& git clone https://github.com/Distrotech/transfig.git && cd transfig \
32+
&& make && make install \
33+
&& cp -R /usr/X11R7/bin/fig2dev /usr/local/bin \
34+
&& if ! getent passwd <%= @username %>; then \
35+
adduser -h /home/<%= @username %> -s /bin/bash <%= @username %>; \
36+
passwd -d <%= @username %>; \
37+
fi \
38+
&& echo "<%= @username %> ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
39+
&& echo "Defaults !requiretty" >> /etc/sudoers \
40+
&& mkdir -p /home/<%= @username %>/.ssh \
41+
&& chown -R <%= @username %> /home/<%= @username %>/.ssh \
42+
&& chmod 0700 /home/<%= @username %>/.ssh \
43+
&& echo '<%= IO.read(@public_key).strip %>' >> /home/<%= @username %>/.ssh/authorized_keys \
44+
&& chown <%= @username %> /home/<%= @username %>/.ssh/authorized_keys \
45+
&& chmod 0600 /home/<%= @username %>/.ssh/authorized_keys \
46+
&& sed -ri 's/^#?PubkeyAuthentication\s+.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config \
47+
&& sed -ri 's/^#?UsePrivilegeSeparation\s+.*/UsePrivilegeSeparation no/' /etc/ssh/sshd_config \
48+
&& echo "UseDNS=no" >> /etc/ssh/sshd_config \
49+
&& ssh-keygen -A
50+
51+
EXPOSE 22
52+
53+
VOLUME [ "/sys/fs/cgroup" ]

.Dockerfiles/ubuntu/rolling/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RUN apt-get update \
77
&& apt-get install -y \
88
apt-utils \
99
curl \
10+
rsync \
1011
locales \
1112
lsb-release \
1213
net-tools \

.ci-tests/integration/gnupg-git/default.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
name: "{{ item }}"
1111
with_items: "{{ build_tools }}"
1212

13-
- name: Check wether deb-src repos are enabled
13+
- name: Check whether deb-src repos are enabled
1414
command: grep -c -e "^deb-src.*" /etc/apt/sources.list
1515
register: deb_src_check
1616
ignore_errors: yes

.ci-tests/integration/gnupg-git/serverspec/default_spec.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
describe command('find /tmp/git-secret/build -name "*.rpm"') do
1111
its(:stdout) { should match /git-secret.*rpm/ }
1212
end
13+
elsif host_inventory['platform'] == 'alpine'
14+
describe command('find /tmp/git-secret/build -name "*.apk"') do
15+
its(:stdout) { should match /git-secret.*apk/ }
16+
end
1317
else
1418
describe command('find /tmp/git-secret/build -name "*.deb"') do
1519
its(:stdout) { should match /git-secret.*deb/ }
@@ -28,17 +32,21 @@
2832
describe command('rpm --query --info git-secret') do
2933
its(:exit_status) { should eq 0 }
3034
end
35+
elsif host_inventory['platform'] == 'alpine'
36+
describe command('apk info git-secret') do
37+
its(:exit_status) { should eq 0 }
38+
end
3139
else
3240
describe command('dpkg-query --status git-secret') do
3341
its(:exit_status) { should eq 0 }
3442
end
3543
end
3644

37-
describe command('man --where "git-secret"') do
45+
describe command('man -w "git-secret"') do
3846
its(:exit_status) { should eq 0 }
3947
end
4048

41-
describe command('man --where "git-secret-init"') do
49+
describe command('man -w "git-secret-init"') do
4250
its(:exit_status) { should eq 0 }
4351
end
4452

.ci-tests/integration/gnupg1/default.yml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
when:
1313
- ansible_distribution == item.distribution
1414
with_items:
15+
- name: gnupg
16+
distribution: Alpine
1517
- name: gnupg
1618
distribution: Fedora
1719
- name: gnupg1

.ci-tests/integration/gnupg1/serverspec/default_spec.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
describe command('find /tmp/git-secret/build -name "*.rpm"') do
1111
its(:stdout) { should match /git-secret.*rpm/ }
1212
end
13+
elsif host_inventory['platform'] == 'alpine'
14+
describe command('find /tmp/git-secret/build -name "*.apk"') do
15+
its(:stdout) { should match /git-secret.*apk/ }
16+
end
1317
else
1418
describe command('find /tmp/git-secret/build -name "*.deb"') do
1519
its(:stdout) { should match /git-secret.*deb/ }
@@ -28,17 +32,21 @@
2832
describe command('rpm --query --info git-secret') do
2933
its(:exit_status) { should eq 0 }
3034
end
35+
elsif host_inventory['platform'] == 'alpine'
36+
describe command('apk info git-secret') do
37+
its(:exit_status) { should eq 0 }
38+
end
3139
else
3240
describe command('dpkg-query --status git-secret') do
3341
its(:exit_status) { should eq 0 }
3442
end
3543
end
3644

37-
describe command('man --where "git-secret"') do
45+
describe command('man -w "git-secret"') do
3846
its(:exit_status) { should eq 0 }
3947
end
4048

41-
describe command('man --where "git-secret-init"') do
49+
describe command('man -w "git-secret-init"') do
4250
its(:exit_status) { should eq 0 }
4351
end
4452

.ci-tests/integration/gnupg2/default.yml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
when:
1313
- ansible_distribution == item.distribution
1414
with_items:
15+
- name: gnupg
16+
distribution: Alpine
1517
- name: gnupg2
1618
distribution: Fedora
1719
- name: gnupg2

.ci-tests/integration/gnupg2/serverspec/default_spec.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
describe command('find /tmp/git-secret/build -name "*.rpm"') do
1111
its(:stdout) { should match /git-secret.*rpm/ }
1212
end
13+
elsif host_inventory['platform'] == 'alpine'
14+
describe command('find /tmp/git-secret/build -name "*.apk"') do
15+
its(:stdout) { should match /git-secret.*apk/ }
16+
end
1317
else
1418
describe command('find /tmp/git-secret/build -name "*.deb"') do
1519
its(:stdout) { should match /git-secret.*deb/ }
@@ -28,17 +32,21 @@
2832
describe command('rpm --query --info git-secret') do
2933
its(:exit_status) { should eq 0 }
3034
end
35+
elsif host_inventory['platform'] == 'alpine'
36+
describe command('apk info git-secret') do
37+
its(:exit_status) { should eq 0 }
38+
end
3139
else
3240
describe command('dpkg-query --status git-secret') do
3341
its(:exit_status) { should eq 0 }
3442
end
3543
end
3644

37-
describe command('man --where "git-secret"') do
45+
describe command('man -w "git-secret"') do
3846
its(:exit_status) { should eq 0 }
3947
end
4048

41-
describe command('man --where "git-secret-init"') do
49+
describe command('man -w "git-secret-init"') do
4250
its(:exit_status) { should eq 0 }
4351
end
4452

.ci-tests/integration/tasks/prep-tests.yml

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
os_pkg_type: "deb"
1212
- os_family: Suse
1313
os_pkg_type: "rpm"
14+
- os_family: Alpine
15+
os_pkg_type: "apk"
1416
changed_when: false
1517
tags:
1618
- skip_ansible_lint
@@ -29,3 +31,6 @@
2931
synchronize:
3032
src: /opt/workspace/
3133
dest: /tmp/git-secret
34+
archive: false
35+
owner: no
36+
recursive: yes

.ci-tests/integration/tasks/run-tests.yml

+2
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@
6363
os_family: "RedHat"
6464
- command: "dpkg --force-all --install"
6565
os_family: "Debian"
66+
- command: "apk add --allow-untrusted"
67+
os_family: "Alpine"

.ci-tests/integration/vars/Alpine.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
test_dependencies:
3+
- gawk
4+
- man
5+
6+
build_tools:
7+
- make

.kitchen.yml

+16
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ transport:
2525
max_ssh_sessions: 3
2626

2727
platforms:
28+
- name: alpine-latest
29+
provisioner:
30+
require_ansible_omnibus: false
31+
driver_config:
32+
run_command: /sbin/tini -v -- /usr/sbin/sshd -D -E /var/log/secure
33+
dockerfile: .Dockerfiles/alpine/latest/Dockerfile
34+
platform: alpine
35+
cap_add:
36+
- SYS_ADMIN
37+
volume:
38+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
39+
- <%=ENV['PWD']%>:/opt/workspace # Make the working directory available inside the container
40+
run_options:
41+
tmpfs:
42+
- /run
43+
2844
- name: debian-stable
2945
driver_config:
3046
run_command: /lib/systemd/systemd

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ matrix:
2121
services: docker
2222
sudo: required
2323
language: ruby
24+
- os: linux
25+
env: GITSECRET_DIST="make"; DOCKER_DIST="alpine"
26+
services: docker
27+
sudo: required
28+
language: ruby
2429
- os: linux
2530
env: GITSECRET_DIST="none"; GITSECRET_GPG_DEP="gnupg"; SECRETS_GPG_COMMAND="gpg"
2631
sudo: false

Makefile

+22
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,28 @@ lint:
9292
install-fpm:
9393
@if [ ! `gem list fpm -i` == "true" ]; then gem install fpm; fi
9494

95+
# .apk:
96+
97+
.PHONY: build-apk
98+
build-apk: clean build install-fpm
99+
@chmod +x "./utils/build-utils.sh"; sync; \
100+
chmod +x "./utils/apk/apk-build.sh"; sync; \
101+
export SECRET_PROJECT_ROOT="${PWD}"; \
102+
"./utils/apk/apk-build.sh"
103+
104+
.PHONY: test-apk-ci
105+
test-apk-ci: install-test build-apk
106+
@chmod +x "./utils/apk/apk-ci.sh"; sync; \
107+
export SECRET_PROJECT_ROOT="${PWD}"; \
108+
export PATH="${PWD}/vendor/bats/bin:${PATH}"; \
109+
"./utils/apk/apk-ci.sh"
110+
111+
.PHONY: deploy-apk
112+
deploy-apk: build-apk
113+
@chmod +x "./utils/apk/apk-deploy.sh"; sync; \
114+
export SECRET_PROJECT_ROOT="${PWD}"; \
115+
"./utils/apk/apk-deploy.sh"
116+
95117
# .deb:
96118

97119
.PHONY: build-deb

utils/apk/apk-build.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# shellcheck disable=SC1090,SC1091
6+
source "${SECRET_PROJECT_ROOT}/utils/build-utils.sh"
7+
8+
preinstall_files "-c"
9+
10+
# Building .deb package:
11+
cd "$SCRIPT_DEST_DIR" && build_package "apk"
12+
13+
# Cleaning up:
14+
clean_up_files && cd "${SECRET_PROJECT_ROOT}"

utils/apk/apk-ci.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# Note that this file is created for test purposes:
6+
# 1. It runs inside the Docker container
7+
# 2. It does not use `sudo` or anything
8+
# 3. If you would like to install `.apk` package on your system, see `Installation`
9+
10+
# shellcheck disable=SC1090,SC1091
11+
source "${SECRET_PROJECT_ROOT}/utils/build-utils.sh"
12+
13+
# This folder should contain just one .apk file:
14+
APK_FILE_LOCATION=$(locate_apk)
15+
16+
17+
# Integration tests
18+
function integration_tests {
19+
# Installing the package:
20+
apk add "$APK_FILE_LOCATION"
21+
22+
# Configuring the dependencies:
23+
apk add --update-cache
24+
25+
# Testing the installation:
26+
apk info | grep "git-secret"
27+
which "git-secret"
28+
29+
# Test the manuals:
30+
man --where "git-secret" # .7
31+
man --where "git-secret-init" # .1
32+
}
33+
34+
integration_tests
35+
36+
# Unit tests:
37+
# shellcheck disable=SC1090,SC1091
38+
source "${SECRET_PROJECT_ROOT}/utils/tests.sh"

utils/apk/apk-deploy.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# shellcheck disable=SC1090,SC1091
6+
source "${SECRET_PROJECT_ROOT}/utils/build-utils.sh"
7+
8+
# Variables, which will be used in `bintray.json`:
9+
SCRIPT_VERSION=$(bash "${PWD}/git-secret" --version)
10+
RELEASE_DATE=$(date +%Y-%m-%d)
11+
12+
# add `\"override\": 1 \` into the `matrixParams`, if needed:
13+
echo "{ \
14+
\"package\": { \
15+
\"name\": \"git-secret\", \
16+
\"repo\": \"apk\", \
17+
\"subject\": \"sobolevn\" \
18+
}, \
19+
\"version\": {
20+
\"name\": \"${SCRIPT_VERSION}\", \
21+
\"desc\": \"Version ${SCRIPT_VERSION}\", \
22+
\"released\": \"${RELEASE_DATE}\", \
23+
\"vcs_tag\": \"v${SCRIPT_VERSION}\", \
24+
\"gpgSign\": true \
25+
}, \
26+
\"files\": [{ \
27+
\"includePattern\": \"build/buildroot/(.*\.apk)\", \
28+
\"uploadPattern\": \"/git-secret_${SCRIPT_VERSION}_all.apk\" \
29+
}], \
30+
\"publish\": true \
31+
}" > "${SECRET_PROJECT_ROOT}/build/apk_descriptor.json"

0 commit comments

Comments
 (0)