mirror of
https://github.com/containers/ramalama.git
synced 2026-02-05 06:46:39 +01:00
konflux: copy source into the bats image
Including the source in the bats image ensures that we're always testing with the same version of the code that was used to build the images. It also eliminates the need for repeated checkouts of the repo and simplifies testing, avoiding additional volumes and artifact references. Signed-off-by: Mike Bonnet <mikeb@redhat.com>
This commit is contained in:
@@ -52,10 +52,6 @@ spec:
|
||||
params:
|
||||
- name: image
|
||||
value: $(tasks.init.results.bats-image)
|
||||
- name: git-url
|
||||
value: $(params.git-url)
|
||||
- name: git-revision
|
||||
value: $(params.git-revision)
|
||||
- name: envs
|
||||
value:
|
||||
- RAMALAMA_IMAGE=$(tasks.init.results.ramalama-image)
|
||||
|
||||
@@ -9,10 +9,6 @@ spec:
|
||||
description: The platform of the VM to provision
|
||||
- name: image
|
||||
description: The image to use when setting up the test environment
|
||||
- name: git-url
|
||||
description: The URL of the source code repository
|
||||
- name: git-revision
|
||||
description: The revision of the source code to test
|
||||
- name: cmd
|
||||
description: The command to run
|
||||
- name: envs
|
||||
@@ -38,10 +34,6 @@ spec:
|
||||
name: ssh
|
||||
workingDir: /var/workdir
|
||||
env:
|
||||
- name: GIT_URL
|
||||
value: $(params.git-url)
|
||||
- name: GIT_REVISION
|
||||
value: $(params.git-revision)
|
||||
- name: TEST_IMAGE
|
||||
value: $(params.image)
|
||||
- name: TEST_CMD
|
||||
@@ -57,13 +49,7 @@ spec:
|
||||
}
|
||||
|
||||
log Install packages
|
||||
dnf -y install openssh-clients rsync git-core jq
|
||||
|
||||
log Clone source
|
||||
git clone -n "$GIT_URL" source
|
||||
pushd source
|
||||
git checkout "$GIT_REVISION"
|
||||
popd
|
||||
dnf -y install openssh-clients rsync jq
|
||||
|
||||
log Prepare connection
|
||||
|
||||
@@ -107,7 +93,7 @@ spec:
|
||||
--security-opt label=disable \
|
||||
--security-opt unmask=/proc/* \
|
||||
--device /dev/net/tun \
|
||||
-v \$PWD/source:/src \
|
||||
--device /dev/fuse \
|
||||
${PODMAN_ENV[*]} \
|
||||
$TEST_IMAGE $TEST_CMD
|
||||
SCRIPTEOF
|
||||
@@ -119,7 +105,7 @@ spec:
|
||||
export SSH_ARGS="-o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ServerAliveCountMax=10"
|
||||
# ssh once before rsync to retrieve the host key
|
||||
ssh $SSH_ARGS "$SSH_HOST" "uname -a"
|
||||
rsync -ra scripts source "$SSH_HOST:$BUILD_DIR"
|
||||
rsync -ra scripts "$SSH_HOST:$BUILD_DIR"
|
||||
ssh $SSH_ARGS "$SSH_HOST" "$BUILD_DIR/scripts/test.sh"
|
||||
log End VM exec
|
||||
else
|
||||
|
||||
@@ -285,8 +285,6 @@ spec:
|
||||
params:
|
||||
- name: image
|
||||
value: $(params.test-image)@$(tasks.wait-for-test-image.results.digest)
|
||||
- name: source-artifact
|
||||
value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
|
||||
- name: envs
|
||||
value:
|
||||
- $(params.test-envs[*])
|
||||
|
||||
@@ -285,8 +285,6 @@ spec:
|
||||
params:
|
||||
- name: image
|
||||
value: $(params.test-image)@$(tasks.wait-for-test-image.results.digest)
|
||||
- name: source-artifact
|
||||
value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
|
||||
- name: envs
|
||||
value:
|
||||
- $(params.test-envs[*])
|
||||
|
||||
@@ -7,58 +7,29 @@ spec:
|
||||
params:
|
||||
- name: image
|
||||
description: The image to use when setting up the test environment.
|
||||
- name: source-artifact
|
||||
description: The Trusted Artifact URI pointing to the artifact with the application source code.
|
||||
- name: cmd
|
||||
description: The command to run.
|
||||
- name: envs
|
||||
description: List of environment variables (NAME=VALUE) to be set in the test environment.
|
||||
type: array
|
||||
default: []
|
||||
volumes:
|
||||
- name: workdir
|
||||
emptyDir: {}
|
||||
stepTemplate:
|
||||
volumeMounts:
|
||||
- mountPath: /var/workdir
|
||||
name: workdir
|
||||
steps:
|
||||
- name: run
|
||||
image: $(params.image)
|
||||
computeResources:
|
||||
limits:
|
||||
memory: 4Gi
|
||||
requests:
|
||||
cpu: "1"
|
||||
memory: 1Gi
|
||||
steps:
|
||||
- name: use-trusted-artifact
|
||||
image: quay.io/konflux-ci/build-trusted-artifacts:latest@sha256:f7d0c515f85aebf926b86d6298f9e2d42d905104506389dc9c3e5878c5c0d38f
|
||||
args:
|
||||
- use
|
||||
- $(params.source-artifact)=/var/workdir/source
|
||||
- name: set-env
|
||||
image: $(params.image)
|
||||
workingDir: /var/workdir/source
|
||||
args:
|
||||
- $(params.envs[*])
|
||||
script: |
|
||||
#!/bin/bash -e
|
||||
rm -f .bashenv
|
||||
while [ $# -ne 0 ]; do
|
||||
echo "$1" >> .bashenv
|
||||
shift
|
||||
done
|
||||
- name: run
|
||||
image: $(params.image)
|
||||
securityContext:
|
||||
capabilities:
|
||||
add:
|
||||
- SETFCAP
|
||||
workingDir: /var/workdir/source
|
||||
env:
|
||||
- name: BASH_ENV
|
||||
value: .bashenv
|
||||
command:
|
||||
- /usr/bin/entrypoint.sh
|
||||
args:
|
||||
- $(params.envs[*])
|
||||
- /bin/bash
|
||||
- -ex
|
||||
- -c
|
||||
|
||||
@@ -25,4 +25,6 @@ RUN git clone --depth=1 https://github.com/ggml-org/llama.cpp && \
|
||||
|
||||
COPY container-images/bats/entrypoint.sh /usr/bin
|
||||
COPY container-images/bats/containers.conf /etc/containers
|
||||
COPY . /src
|
||||
RUN chmod -R a+rw /src
|
||||
RUN chmod a+rw /etc/subuid /etc/subgid
|
||||
|
||||
@@ -3,6 +3,16 @@
|
||||
echo "$(id -un):10000:2000" > /etc/subuid
|
||||
echo "$(id -un):10000:2000" > /etc/subgid
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
if [[ "$1" =~ = ]]; then
|
||||
# shellcheck disable=SC2163
|
||||
export "$1"
|
||||
shift
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
exec "$@"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user