Skip to content

Commit

Permalink
Add build tests
Browse files Browse the repository at this point in the history
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
  • Loading branch information
pierDipi committed Feb 13, 2025
1 parent de31c89 commit 8ae76bc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
4 changes: 4 additions & 0 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

source "$(dirname $0)/common.sh"

export KO_DOCKER_REPO="${KO_DOCKER_REPO:-kind.local}"

build_transform_jsonata_image || exit 1

build_integration_images || exit 1
11 changes: 9 additions & 2 deletions hack/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@ readonly REPO_ROOT_DIR
function build_transform_jsonata_image() {
local image="${KO_DOCKER_REPO}/transform-jsonata:${TAG}"

docker buildx build \
docker build \
--platform linux/amd64,linux/arm64 \
-t "${image}" \
-f "${REPO_ROOT_DIR}/transform-jsonata/Dockerfile" \
--push \
"${REPO_ROOT_DIR}/transform-jsonata" || return $?


TRANSFORM_JSONATA_IMAGE=$(docker inspect --format '{{index .RepoDigests 0}}' "${image}")
export TRANSFORM_JSONATA_IMAGE
}

function push_transform_jsonata_image() {
docker push "${TRANSFORM_JSONATA_IMAGE}"
}

function build_integration_images() {
"${REPO_ROOT_DIR}/mvnw" clean package -P knative -DskipTests || return $?
}
3 changes: 2 additions & 1 deletion hack/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ function build_release() {

# KO_DOCKER_REPO and TAG are calculated in release.sh script

./mvnw clean package -P knative -DskipTests || return $?
build_integration_images || return $?

# use the function so that the exported TRANSFORM_JSONATA_IMAGE is visible after during generate_transformation_configMap
build_transform_jsonata_image || return $?
push_transform_jsonata_image || return $?

echo "Image build & push completed"

Expand Down
12 changes: 8 additions & 4 deletions test/presubmit-tests.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/usr/bin/env bash

# TODO a placeholder script to CI automation.
# Can be used to execute integration tests in the future.
# shellcheck disable=SC1090
source "$(go run knative.dev/hack/cmd/script presubmit-tests.sh)"
source "$(go run knative.dev/hack/cmd/script infra-library.sh)"

./hack/build.sh
function build_tests() {
header "Running build tests"
./hack/build.sh || fail_test "build tests failed"
}

true
main $@

0 comments on commit 8ae76bc

Please sign in to comment.