Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 871d167

Browse files
Katherine BlackKatherine Black
authored andcommitted
Add build_deploy.sh and pr_check.sh
1 parent 8c32b0e commit 871d167

File tree

4 files changed

+70
-28
lines changed

4 files changed

+70
-28
lines changed

Dockerfile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Builder Stage
12
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 as builder
23

34
ENV LANG=en_US.utf8
@@ -20,11 +21,11 @@ RUN microdnf update \
2021
&& if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3.9 /usr/bin/python; fi \
2122
&& if [ ! -e /usr/bin/pip ]; then ln -s /usr/bin/pip3.9 /usr/bin/pip ; fi \
2223
&& pip install -U pip \
23-
&& pip install poetry \
24+
&& pip install poetry tox \
2425
&& poetry config virtualenvs.in-project true \
2526
&& poetry install -n --no-dev
2627

27-
28+
# Release Stage
2829
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 as release
2930

3031
ENV LANG=en_US.utf8
@@ -47,3 +48,14 @@ COPY houndigrade/cli.py .
4748

4849
ENTRYPOINT ["python", "cli.py"]
4950
CMD ["--help"]
51+
52+
# PR Check Stage
53+
FROM builder as pr_check
54+
55+
COPY tox.ini .
56+
COPY houndigrade/ houndigrade/
57+
58+
RUN tox
59+
60+
# Decalre "default" stage.
61+
FROM release

build_deploy.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

deployment/scripts/build_deploy.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
DOCKER_CONF="${PWD}/.docker"
4+
5+
IMAGE_NAME="quay.io/cloudservices/houndigrade"
6+
GIT_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
7+
8+
if [[ -z "$QUAY_USER" || -z "$QUAY_TOKEN" ]]; then
9+
echo "QUAY_USER and QUAY_TOKEN must be set"
10+
exit 1
11+
fi
12+
13+
if [[ -z "$RH_REGISTRY_USER" || -z "$RH_REGISTRY_TOKEN" ]]; then
14+
echo "RH_REGISTRY_USER and RH_REGISTRY_TOKEN must be set"
15+
exit 1
16+
fi
17+
18+
mkdir -p "${DOCKER_CONF}"
19+
20+
# Log into the registries
21+
docker --config="${DOCKER_CONF}" login -u="${QUAY_USER}" -p="${QUAY_TOKEN}" quay.io
22+
docker --config="${DOCKER_CONF}" login -u="$RH_REGISTRY_USER" -p="$RH_REGISTRY_TOKEN" registry.redhat.io
23+
24+
# Check if semver tagged image already exists, or this is the first build of it.
25+
if [[ ! "docker --config="${DOCKER_CONF}" pull ${IMAGE_NAME}:${GIT_TAG}" ]]; then
26+
echo "First time encountering ${GIT_TAG}, building..."
27+
push_git_tag=true
28+
else
29+
echo "${GIT_TAG} already exists, skipping building tag."
30+
fi
31+
32+
# Pull 'Latest' Image
33+
docker --config="${DOCKER_CONF}" pull ${IMAGE_NAME}:latest || true
34+
35+
# Build and Tag
36+
docker --config="${DOCKER_CONF}" build --cache-from ${IMAGE_NAME}:latest --tag "${IMAGE_NAME}:latest" .
37+
if [[ "$push_git_tag" = true ]]; then
38+
docker --config="${DOCKER_CONF}" tag "${IMAGE_NAME}:latest" "${IMAGE_NAME}:${GIT_TAG}"
39+
fi
40+
41+
# Push images
42+
docker --config="${DOCKER_CONF}" push "${IMAGE_NAME}:latest"
43+
if [[ "$push_git_tag" = true ]]; then
44+
docker --config="${DOCKER_CONF}" push "${IMAGE_NAME}:${GIT_TAG}"
45+
fi

deployment/scripts/pr_check.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Run the PR Check build stage
4+
docker build --target pr_check .
5+
6+
mkdir -p artifacts
7+
cat << EOF > artifacts/junit-dummy.xml
8+
<testsuite tests="1">
9+
<testcase classname="dummy" name="dummytest"/>
10+
</testsuite>
11+
EOF

0 commit comments

Comments
 (0)