Skip to content

Commit 3e0965b

Browse files
authored
Merge pull request #15 from sarus-suite/fc-bats-on-runner
Add basic extra test capability. Fixes CI image to use CMD rather than entrypoint, which facilitates usage.
2 parents eeac0d7 + 70f91ea commit 3e0965b

File tree

4 files changed

+140
-11
lines changed

4 files changed

+140
-11
lines changed

.github/containers/Containerfile.ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ RUN set -eux; \
3535
ENV PATH=$PATH:/usr/local/go/bin
3636

3737
# Default entrypoint
38-
ENTRYPOINT ["bash"]
38+
CMD ["bash"]
3939

.github/workflows/unified-vs-test.yml

Lines changed: 127 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,138 @@ name: Run on Zinal
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches:
6+
- 'fc-*'
67

78
jobs:
89
build:
10+
if: github.actor == 'fcruzcscs'
911
runs-on: zinal
1012
steps:
11-
- name: Checkout code
12-
uses: actions/checkout@v4
13+
- name: Setup temporary dir
14+
run: |
15+
TMP_DIR=$(mktemp -d)
16+
echo "TMP_DIR=$TMP_DIR" >> $GITHUB_ENV
17+
echo "Using temp directory: $TMP_DIR"
18+
19+
- name: Manually clone repo within tmp dir
20+
run: git clone --depth 1 --branch "${GITHUB_REF_NAME}" https://github.com/${GITHUB_REPOSITORY}.git
21+
working-directory: ${{ env.TMP_DIR }}
22+
23+
- name: List contents of TMP_DIR
24+
run: ls -la
25+
working-directory: ${{ env.TMP_DIR }}
26+
27+
- name: Run build inside Podman container
28+
run: |
29+
podman run --rm \
30+
-v "$PWD":"$PWD":Z \
31+
-v "$TMP_DIR":"$TMP_DIR":Z \
32+
-w "$PWD" \
33+
--env TMP_DIR="$TMP_DIR" \
34+
--env GITHUB_REF_NAME="$GITHUB_REF_NAME" \
35+
ghcr.io/sarus-suite/parallax/ci-runner:latest \
36+
bash -euxc '
37+
mkdir -p $TMP_DIR/dist
38+
39+
go version
40+
41+
export VER=opensuse-15.5
42+
export HOST_ARCH="$(go env GOHOSTARCH)"
43+
#export OUT="parallax-${GITHUB_REF_NAME}-${VER}-${HOST_ARCH}"
44+
export OUT="parallax"
45+
46+
go get .
47+
48+
export CGO_ENABLED=1
49+
export CC=gcc
50+
export GOFLAGS="-buildvcs=false"
51+
export GO_LDFLAGS="-linkmode external"
52+
export CGO_LDFLAGS="-g -O2"
53+
export GOARCH="$HOST_ARCH"
54+
export GOOS=linux
55+
56+
go build -v \
57+
-o "$TMP_DIR/dist/$OUT" \
58+
.
59+
echo Built binary: "$TMP_DIR/dist/$OUT"
60+
'
61+
working-directory: ${{ env.TMP_DIR }}/parallax
62+
63+
- name: Install Bats locally
64+
run: |
65+
git clone --depth 1 https://github.com/bats-core/bats-core.git "$TMP_DIR/bats-core"
66+
"$TMP_DIR/bats-core/install.sh" "$TMP_DIR/bats"
67+
working-directory: ${{ env.TMP_DIR }}
68+
69+
- name: Testing podman run
70+
run: |
71+
export PODMAN_BINARY=$(which podman)
72+
$PODMAN_BINARY version
73+
export PARALLAX_BINARY=$TMP_DIR/dist/parallax
74+
$PARALLAX_BINARY --version
75+
working-directory: ${{ env.TMP_DIR}}
76+
77+
- name: Simple parallax test
78+
run: |
79+
# Setup env
80+
export PODMAN_BINARY=$(which podman)
81+
export PARALLAX_BINARY=$TMP_DIR/dist/parallax
82+
export MOUNT_PROGRAM_PATH=$TMP_DIR/parallax/scripts/parallax-mount-program.sh
83+
export PARALLAX_MP_SQUASHFUSE_FLAG="-o nonempty"
84+
export PODMAN_ROOT="$(mktemp -d)"
85+
export PODMAN_RUNROOT="$(mktemp -d)"
86+
export RO_STORAGE="$(mktemp -d)"
87+
export CLEAN_ROOT="$(mktemp -d)"
88+
export MKSQUASHFS_PATH="$(command -v mksquashfs)"
89+
90+
# Test podman + parallax
91+
"$PODMAN_BINARY" \
92+
--root "$PODMAN_ROOT" \
93+
--runroot "$PODMAN_RUNROOT" \
94+
pull busybox:latest
95+
96+
"$PARALLAX_BINARY" \
97+
--podmanRoot "$PODMAN_ROOT" \
98+
--roStoragePath "$RO_STORAGE" \
99+
--mksquashfsPath "$MKSQUASHFS_PATH" \
100+
--log-level info \
101+
--migrate \
102+
--image busybox:latest
103+
104+
"$PODMAN_BINARY" \
105+
--root "$CLEAN_ROOT" \
106+
--runroot "$PODMAN_RUNROOT" \
107+
--storage-opt additionalimagestore=$RO_STORAGE \
108+
--storage-opt mount_program=$MOUNT_PROGRAM_PATH \
109+
images
110+
111+
"$PODMAN_BINARY" \
112+
--root "$CLEAN_ROOT" \
113+
--runroot "$PODMAN_RUNROOT" \
114+
--storage-opt additionalimagestore=$RO_STORAGE \
115+
--storage-opt mount_program=$MOUNT_PROGRAM_PATH \
116+
run --rm $PODMAN_RUN_OPTIONS busybox:latest echo ok
117+
118+
"$PODMAN_BINARY" \
119+
--root "$PODMAN_ROOT" \
120+
--runroot "$PODMAN_RUNROOT" \
121+
--storage-opt mount_program=$MOUNT_PROGRAM_PATH \
122+
rmi --all
123+
124+
rm -rf "$PODMAN_ROOT"
125+
rm -rf "$PODMAN_RUNROOT"
126+
rm -rf "$CLEAN_ROOT"
127+
#rm -rf "$RO_STORAGE"
128+
working-directory: ${{ env.TMP_DIR}}
13129

14-
- name: Run a script
130+
- name: Run Bats tests
15131
run: |
16-
echo "Hello from zinal runner!"
17-
uname -a
132+
export PODMAN_BINARY=$(which podman)
133+
export PARALLAX_BINARY=$TMP_DIR/dist/parallax
134+
export MOUNT_PROGRAM_PATH=$TMP_DIR/parallax/scripts/parallax-mount-program.sh
135+
export PARALLAX_MP_SQUASHFUSE_FLAG="-o nonempty"
136+
cd parallax
137+
$TMP_DIR/bats/bin/bats tests
138+
working-directory: ${{ env.TMP_DIR}}
18139

scripts/parallax-mount-program.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ fi
3636
: "${PARALLAX_MP_INOTIFYWAIT_CMD:=inotifywait}"
3737
: "${PARALLAX_MP_FUSE_OVERLAYFS_CMD:=fuse-overlayfs}"
3838
: "${PARALLAX_MP_SQUASHFUSE_CMD:=squashfuse}"
39+
# ignore squashfuse flag if not set
40+
#: "${PARALLAX_MP_SQUASHFUSE_FLAG:=''}"
3941

4042
REQUIRED_CFG_VARS=(
4143
PARALLAX_MP_INOTIFYWAIT_CMD
@@ -163,9 +165,15 @@ do_squash_mount() {
163165
local squash_file="$1"
164166
local target_dir="$2"
165167

168+
if [[ -n "$PARALLAX_MP_SQUASHFUSE_FLAG" ]]; then
169+
IFS=' ' read -r -a PARALLAX_MP_SQUASHFUSE_FLAG_ARR <<< "$PARALLAX_MP_SQUASHFUSE_FLAG"
170+
else
171+
PARALLAX_MP_SQUASHFUSE_FLAG_ARR=()
172+
fi
173+
166174
# Here we only check if link is a symlink to the actual squash file, as this is what Parallax migration does
167-
if [ -h "$squash_file" ]; then
168-
run_and_log "Mounting squash file." "$SQUASHFUSE_CMD" "$squash_file" "$target_dir"
175+
if [ -h "$squash_file" ]; then
176+
run_and_log "Mounting squash file." "$SQUASHFUSE_CMD" "$squash_file" "$target_dir" ${PARALLAX_MP_SQUASHFUSE_FLAG_ARR[@]}
169177
if [ $? -ne 0 ]; then
170178
handle_error "squashfuse failed"
171179
fi

tests/helpers.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
export PODMAN_BINARY="${PODMAN_BINARY:-/mnt/nfs/git/podman/bin/podman}"
66
export PARALLAX_BINARY="${PARALLAX_BINARY:-/mnt/nfs/git/parallax/parallax}"
7-
export MOUNT_PROGRAM_PATH="/mnt/nfs/git/parallax/scripts/parallax-mount-program.sh"
8-
export PODMAN_RUN_OPTIONS="--security-opt seccomp=unconfined"
7+
export MOUNT_PROGRAM_PATH="${MOUNT_PROGRAM_PATH:-/mnt/nfs/git/parallax/scripts/parallax-mount-program.sh}"
8+
export PODMAN_RUN_OPTIONS="${PODMAN_RUN_OPTIONS:---security-opt seccomp=unconfined}"
99

1010
setup() {
1111
# Seting up temp dirs and env vars

0 commit comments

Comments
 (0)