diff --git a/.ciux b/.ciux index f3b2ab6d3..eee2d67d6 100644 --- a/.ciux +++ b/.ciux @@ -40,7 +40,7 @@ dependencies: - image: gitlab-registry.in2p3.fr/astrolabsoftware/fink/fink-deps-science-ztf:latest labels: build: "science" - - package: github.com/k8s-school/ktbx@v1.1.4-rc7 + - package: github.com/k8s-school/ktbx@v1.1.6-rc5 labels: itest: "optional" - package: github.com/astrolabsoftware/finkctl/v3@v3.1.3-rc3 diff --git a/.github/workflows/e2e-common.yml b/.github/workflows/e2e-common.yml index 7acd97dc8..7c610cce5 100644 --- a/.github/workflows/e2e-common.yml +++ b/.github/workflows/e2e-common.yml @@ -13,6 +13,11 @@ on: required: false type: string default: "v0.20.0" + skip_artifacts: + description: 'Skip artifact upload/download (for self-hosted runners)' + required: false + type: boolean + default: false secrets: registry_username: required: true @@ -24,16 +29,17 @@ env: CIUX_VERSION: v0.0.7-rc1 GHA_BRANCH_NAME: ${{ github.head_ref || github.ref_name }} SUFFIX: ${{ inputs.suffix }} - STORAGE: ${{ inputs.storage }} MONITORING_OPT: "-m" # Override the self-hosted runner value POD_NAMESPACE: default + SHARED_IMAGE_PATH: "/tmp/fink-ci-image.tar" jobs: build: name: Build image runs-on: ${{ fromJSON(inputs.runner) }} outputs: - image: ${{ steps.export.outputs.IMAGE }} + ciux_image_url: ${{ steps.export.outputs.CIUX_IMAGE_URL }} + skip_artifacts: ${{ steps.export.outputs.skip_artifacts }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -51,18 +57,33 @@ jobs: - name: Export fink-broker image id: export run: | - mkdir -p artifacts # Cannot use CIUXCONFIG because it may not have been created yet $(ciux get image --check $PWD --suffix "${{ env.SUFFIX }}" --env) if [ $CIUX_BUILD = true ]; then + if [ "${{ inputs.skip_artifacts }}" = "true" ]; then + # For self-hosted: save image to shared location to persist between jobs + SHARED_IMAGE_PATH="${{ env.SHARED_IMAGE_PATH }}" + echo "Removing existing shared image file $SHARED_IMAGE_PATH" + rm -f "$SHARED_IMAGE_PATH" + echo "Saving image $CIUX_IMAGE_URL to $SHARED_IMAGE_PATH" + docker save "$CIUX_IMAGE_URL" -o "$SHARED_IMAGE_PATH" + echo "CIUX_IMAGE_URL=$CIUX_IMAGE_URL" >> "$GITHUB_OUTPUT" + echo "SHARED_IMAGE_PATH=$SHARED_IMAGE_PATH" >> "$GITHUB_OUTPUT" + else + # For GitHub runners: use artifacts + mkdir -p artifacts echo "Export $CIUX_IMAGE_URL to Github artifact store" docker save "$CIUX_IMAGE_URL" > artifacts/image.tar + echo "CIUX_IMAGE_URL=$CIUX_IMAGE_URL" >> "$GITHUB_OUTPUT" + fi + echo "skip_artifacts=${{ inputs.skip_artifacts }}" >> "$GITHUB_OUTPUT" else echo "Using existing image $CIUX_IMAGE_URL" - touch artifacts/empty + echo "skip_artifacts=true" >> "$GITHUB_OUTPUT" + echo "CIUX_IMAGE_URL=$CIUX_IMAGE_URL" >> "$GITHUB_OUTPUT" fi - echo "IMAGE=$CIUX_IMAGE_URL" >> "$GITHUB_OUTPUT" - uses: actions/upload-artifact@v4 + if: ${{ steps.export.outputs.skip_artifacts != 'true' }} with: name: docker-artifact path: artifacts @@ -73,8 +94,8 @@ jobs: name: Run integration tests runs-on: ${{ fromJSON(inputs.runner) }} outputs: - new_image: ${{ steps.promote.outputs.NEW_IMAGE }} - promoted_image: ${{ steps.promote.outputs.PROMOTED_IMAGE }} + ciux_build: ${{ steps.promote.outputs.CIUX_BUILD }} + ciux_promoted_image_url: ${{ steps.promote.outputs.CIUX_PROMOTED_IMAGE_URL }} needs: build steps: - name: Checkout code @@ -109,14 +130,30 @@ jobs: run: | # v0.20.0 does not work on self-hosted runners ./e2e/prereq-install.sh -k "${{ inputs.kind_version }}" ${{ env.MONITORING_OPT}} + - name: Download image uses: actions/download-artifact@v4 + if: ${{ needs.build.outputs.skip_artifacts != 'true' }} with: name: docker-artifact path: artifacts - name: Load container image inside kind run: | - if [ -f artifacts/image.tar ]; then + if [ "${{ inputs.skip_artifacts }}" = "true" ]; then + # For self-hosted: load from shared location + SHARED_IMAGE_PATH="${{ env.SHARED_IMAGE_PATH }}" + if [ -f "$SHARED_IMAGE_PATH" ]; then + echo "Loading image ${{ needs.build.outputs.ciux_image_url }} from $SHARED_IMAGE_PATH" + docker load -i "$SHARED_IMAGE_PATH" + cluster_name=$(ciux get clustername $PWD) + kind load docker-image "${{ needs.build.outputs.ciux_image_url }}" --name "$cluster_name" + node=$(kubectl get nodes --selector=node-role.kubernetes.io/control-plane -o jsonpath='{.items[0].metadata.name}') + docker exec -- $node crictl image + else + echo "Error: shared image file $SHARED_IMAGE_PATH not found" + exit 1 + fi + elif [ -f artifacts/image.tar ]; then echo "Loading image from archive" cluster_name=$(ciux get clustername $PWD) kind load image-archive artifacts/image.tar --name "$cluster_name" @@ -135,12 +172,17 @@ jobs: - name: Check results run: | ./e2e/check-results.sh + - name: Delete cluster + if: always() + run: | + cluster_name=$(ciux get clustername $PWD) + kind delete cluster --name "$cluster_name" - name: Promote fink-broker image id: promote run: | . .ciux.d/ciux_itest.sh - echo "PROMOTED_IMAGE=$CIUX_PROMOTED_IMAGE_URL" >> "$GITHUB_OUTPUT" - echo "NEW_IMAGE=$CIUX_BUILD" >> "$GITHUB_OUTPUT" + echo "CIUX_PROMOTED_IMAGE_URL=$CIUX_PROMOTED_IMAGE_URL" >> "$GITHUB_OUTPUT" + echo "CIUX_BUILD=$CIUX_BUILD" >> "$GITHUB_OUTPUT" image-analysis: name: Analyze image runs-on: ${{ fromJSON(inputs.runner) }} @@ -152,22 +194,33 @@ jobs: uses: actions/checkout@v3 - name: Download image uses: actions/download-artifact@v4 + if: ${{ !needs.build.outputs.skip_artifacts }} with: name: docker-artifact path: artifacts - name: Load image in local registry run: | - if [ -f artifacts/image.tar ]; then - echo "Loading image ${{ needs.build.outputs.image }} from archive" + if [ "${{ inputs.skip_artifacts }}" = "true" ]; then + # For self-hosted: load from shared location + SHARED_IMAGE_PATH="${{ env.SHARED_IMAGE_PATH }}" + if [ -f "$SHARED_IMAGE_PATH" ]; then + echo "Loading image ${{ needs.build.outputs.ciux_image_url }} from $SHARED_IMAGE_PATH" + docker load -i "$SHARED_IMAGE_PATH" + else + echo "Error: shared image file $SHARED_IMAGE_PATH not found" + exit 1 + fi + elif [ -f artifacts/image.tar ]; then + echo "Loading image ${{ needs.build.outputs.ciux_image_url }} from archive" docker load --input artifacts/image.tar else - echo "Using existing image ${{ needs.build.outputs.image }}" + echo "Using existing image ${{ needs.build.outputs.ciux_image_url }}" fi - name: Scan fink-broker image uses: anchore/scan-action@v6 id: scan with: - image: "${{ needs.build.outputs.image }}" + image: "${{ needs.build.outputs.ciux_image_url }}" fail-build: false - name: Display SARIF report run: | @@ -178,32 +231,42 @@ jobs: sarif_file: ${{ steps.scan.outputs.sarif }} push: env: - NEW_IMAGE: ${{ needs.integration-tests.outputs.new_image }} - IMAGE: ${{ needs.build.outputs.image }} - PROMOTED_IMAGE: ${{ needs.integration-tests.outputs.promoted_image }} + CIUX_BUILD: ${{ needs.integration-tests.outputs.ciux_build }} + CIUX_IMAGE_URL: ${{ needs.build.outputs.ciux_image_url }} + CIUX_PROMOTED_IMAGE_URL: ${{ needs.integration-tests.outputs.ciux_promoted_image_url }} name: Push fink-broker image to IN2P3 registry runs-on: ${{ fromJSON(inputs.runner) }} needs: [build, integration-tests] steps: - name: Download image uses: actions/download-artifact@v4 + if: ${{ !needs.build.outputs.skip_artifacts }} with: name: docker-artifact path: artifacts - name: Load image in local registry run: | - if [ $NEW_IMAGE = true ]; then - # GHA setup - if [ -f artifacts/image.tar ]; then - echo "Loading image "$IMAGE" from archive" + if [ $CIUX_BUILD = true ]; then + if [ "${{ inputs.skip_artifacts }}" = "true" ]; then + # For self-hosted: load from shared location + SHARED_IMAGE_PATH="${{ env.SHARED_IMAGE_PATH }}" + if [ -f "$SHARED_IMAGE_PATH" ]; then + echo "Loading image $CIUX_IMAGE_URL from $SHARED_IMAGE_PATH" + docker load -i "$SHARED_IMAGE_PATH" + else + echo "Error: shared image file $SHARED_IMAGE_PATH not found" + exit 1 + fi + elif [ -f artifacts/image.tar ]; then + # GHA setup + echo "Loading image $CIUX_IMAGE_URL from archive" docker load --input artifacts/image.tar - # Self-hosted runners, new image is stored in the local registry else - echo "Error: no image found" + echo "Error: no image source available" exit 1 fi else - echo "Using existing image $IMAGE" + echo "Using existing image $CIUX_IMAGE_URL" fi - name: Login to DockerHub uses: docker/login-action@v2 @@ -211,26 +274,31 @@ jobs: registry: gitlab-registry.in2p3.fr username: ${{ secrets.registry_username }} password: ${{ secrets.registry_token }} + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v4 + with: + go-version: '1.21.4' + - name: Install ciux + run: go install github.com/k8s-school/ciux@"${{ env.CIUX_VERSION }}" - name: Push image to official registry run: | - if [ $NEW_IMAGE = true ]; then - echo "Push image $PROMOTED_IMAGE" - docker tag "$IMAGE" "$PROMOTED_IMAGE" - docker push "$PROMOTED_IMAGE" - else - if which skopeo; then - echo "skopeo is already installed" - else - echo "Install skopeo" - sudo apt-get update -y - sudo apt-get install -y skopeo - fi - echo "Add image tag $PROMOTED_IMAGE to $IMAGE" - skopeo copy docker://$IMAGE docker://$PROMOTED_IMAGE - fi + ./push-image.sh - uses: act10ns/slack@v1 with: webhook-url: ${{ secrets.slack_webhook_url }} status: ${{ job.status }} if: always() + - name: Cleanup shared image file + run: | + if [ "${{ inputs.skip_artifacts }}" = "true" ]; then + SHARED_IMAGE_PATH="${{ env.SHARED_IMAGE_PATH }}" + if [ -f "$SHARED_IMAGE_PATH" ]; then + echo "Removing shared image file $SHARED_IMAGE_PATH" + rm -f "$SHARED_IMAGE_PATH" + fi + fi + if: always() diff --git a/.github/workflows/e2e-k8s-ztf-science-self-hosted.yml b/.github/workflows/e2e-k8s-ztf-science-self-hosted.yml index 248e1a5be..a2df82b5c 100644 --- a/.github/workflows/e2e-k8s-ztf-science-self-hosted.yml +++ b/.github/workflows/e2e-k8s-ztf-science-self-hosted.yml @@ -14,6 +14,7 @@ jobs: with: suffix: "" runner: "['self-hosted']" + skip_artifacts: true secrets: registry_username: ${{ secrets.REGISTRY_USERNAME }} registry_token: ${{ secrets.REGISTRY_TOKEN }} diff --git a/.gitignore b/.gitignore index c9f3de892..d9c5c0ec4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /secret.yaml +/e2e-report.yaml /.ciux.d /.claude /\#TODO.org\# diff --git a/TODO.931 b/TODO.931 deleted file mode 100644 index 5d11c10bd..000000000 --- a/TODO.931 +++ /dev/null @@ -1,3 +0,0 @@ -Downgrade JMX experter w.r.t spark doc and test dashboard: 7890 - -C'est quoi: https://github.com/monitoring-mixins/website/blob/master/assets/spark/dashboards/spark-metrics.json diff --git a/TODO.latest b/TODO.latest deleted file mode 100644 index d6f612bed..000000000 --- a/TODO.latest +++ /dev/null @@ -1,2 +0,0 @@ -Does not pick the correct fink-cd branch -https://productionresultssa19.blob.core.windows.net/actions-results/ddfbe6e1-e2f0-477b-80dd-fcf1a1f7a5a8/workflow-job-run-68d9c067-2b13-539b-afb0-a5aace24f271/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-03-31T15%3A45%3A08Z&sig=qEGCrwJ8KxbO8ybb40lPEb%2B2XC1wr3CLUOicJFnL5II%3D&ske=2025-03-31T23%3A54%3A22Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-03-31T11%3A54%3A22Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-01-05&sp=r&spr=https&sr=b&st=2025-03-31T15%3A35%3A03Z&sv=2025-01-05 diff --git a/build.sh b/build.sh index 2f0de3c9c..9f2833c19 100755 --- a/build.sh +++ b/build.sh @@ -77,9 +77,6 @@ fi ciux ignite --selector "$SELECTOR" $DIR --suffix "$suffix" - -# TODO improve and use -# . $DIR/.ciux.d/ciuxconfig.sh CIUXCONFIG=$(ciux get configpath --selector $SELECTOR $DIR) echo "Sourcing ciux config from $CIUXCONFIG" . $CIUXCONFIG diff --git a/e2e/check-results.sh b/e2e/check-results.sh index 6e678a495..047a581de 100755 --- a/e2e/check-results.sh +++ b/e2e/check-results.sh @@ -64,38 +64,65 @@ else expected_topics="16" fi +# Wait for topics to be created, and check if fink-broker has not crashed in the meantime +# display logs of failed pods if any, and of running pods if no topics after 10 attempts (~10 minutes) count=0 +max_attempts=10 +selector="spark-app-name" +err_msg="" while ! finkctl wait topics --expected "$expected_topics" --timeout 60s -v1 > /dev/null do - echo "INFO: Waiting for expected topics: $expected_topics" + echo "INFO: Waiting for expected topics: $expected_topics, attempt: $((count+1))/$max_attempts" sleep 5 echo "INFO: List pods in spark namespace:" kubectl get pods -n spark - if [ $(kubectl get pods -n spark -l app.kubernetes.io/instance=fink-broker --field-selector=status.phase!=Running | wc -l) -ge 1 ]; - then - echo "ERROR: fink-broker has crashed" 1>&2 - # Useful for debugging on github actions - echo "ERROR: enabling interactive access for debugging purpose" 1>&2 - kubectl get pods -n spark -l app.kubernetes.io/instance=fink-broker - sleep 7200 - exit 1 + + crashed_pods=$(kubectl get pods -n spark -l $selector --field-selector=status.phase=Failed -o name) + if [ -n "$crashed_pods" ]; then + echo "ERROR: crashed pods found: $crashed_pods" 1>&2 + for pod in $crashed_pods + do + echo "--- Logs for crashed Pod: $pod ---" + kubectl logs "$pod" -n spark + done + running_pods=$(kubectl get pods -n spark -l $selector --field-selector=status.phase=Running -o name) + if [ -n "$running_pods" ]; then + echo "INFO: logs of running pods:" + for pod in $running_pods; do + echo "--- Logs for running Pod: $pod ---" + kubectl logs "$pod" -n spark --tail -1 + done + fi + err_msg="ERROR: fink-broker has crashed" 1>&2 + # echo "ERROR: enabling interactive access for debugging purpose" 1>&2 + # sleep 7200 + break fi + count=$((count+1)) - if [ $count -eq 10 ]; then - echo "ERROR: Timeout waiting for topics to be created" 1>&2 - kubectl logs -l sparkoperator.k8s.io/launched-by-spark-operator=true --tail -1 - echo "PODS" - kubectl get pods -A - echo "FINK KAFKA TOPICS" - finkctl get topics - sleep 7200 - exit 1 + if [ $count -eq $max_attempts ]; then + pods=$(kubectl get pods -n spark -l $selector -o name) + for pod in $pods + do + echo "--- Logs for Pod: $pod ---" + kubectl logs "$pod" -n spark --tail -1 + done + err_msg="ERROR: fink-broker did not produce expected results after ~10 minutes" + # echo "ERROR: enabling interactive access for debugging purpose" 1>&2 + # sleep 7200 + break fi done finkctl get topics +if [ -n "$err_msg" ]; then + echo "$err_msg" 1>&2 + exit 1 +fi + if $monitoring; then + echo "Checking prometheus exporter is enabled in fink-broker" if kubectl exec -it -n spark fink-broker-stream2raw-driver -- curl http://localhost:8090/metrics | grep jvm > /dev/null then echo "Prometheus exporter is enabled" @@ -119,4 +146,5 @@ then fi + echo "INFO: Fink-broker is running and all topics are created" diff --git a/e2e/clean.sh b/e2e/clean.sh new file mode 100755 index 000000000..c17fde2b8 --- /dev/null +++ b/e2e/clean.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -euxo pipefail + +DIR=$(cd "$(dirname "$0")"; pwd -P) + +CLUSTER_NAME=$(ciux get clustername "$DIR/..") +ktbx delete --name "$CLUSTER_NAME" \ No newline at end of file diff --git a/e2e/run.sh b/e2e/run.sh index 5249b849f..f5491b319 100755 --- a/e2e/run.sh +++ b/e2e/run.sh @@ -8,6 +8,29 @@ set -euxo pipefail DIR=$(cd "$(dirname "$0")"; pwd -P) +START_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + + +export ARGOCD_CONFIG_PATH=/var/lib/fink-ci/argocd.config + +# Test report file (YAML format for better GHA integration) +HOME_CI_RESULT_FILE="${HOME_CI_RESULT_FILE:-}" +if [ -z "$HOME_CI_RESULT_FILE" ]; then + TEST_REPORT="$DIR/../e2e-report.yaml" + echo "WARNING: HOME_CI_RESULT_FILE is not set, using temporary file $TEST_REPORT" +else + TEST_REPORT="$HOME_CI_RESULT_FILE" +fi + +# Create log directory if it doesn't exist +mkdir -p "$(dirname "$TEST_REPORT")" + + +echo "=== Fink-Broker E2E Test Suite ===" +echo "Start time: $START_TIME" +echo "Test report: $TEST_REPORT" +echo "==================================" + usage () { echo "Usage: $0 [-c] [-h] [-m] [-s]" echo " -s: Use the science algorithms during the tests" @@ -37,7 +60,7 @@ input_survey="ztf" token="${TOKEN:-}" # Get options for suffix -while getopts hcmsiS: opt; do +while getopts hcmsi:S: opt; do case ${opt} in c ) @@ -66,78 +89,87 @@ done export SUFFIX -function dispatch() -{ - if [ "$SUFFIX" = "" ]; then - echo "Running e2e tests with science algorithms" - event_type="e2e-science" - else - echo "Running e2e tests without science algorithms" - event_type="e2e-noscience" - fi - - url="https://api.github.com/repos/astrolabsoftware/fink-broker/dispatches" - - payload="{\"build\": $build,\"e2e\": $e2e,\"push\": $push, \"cluster\": \"$cluster\", \"image\": \"$CIUX_IMAGE_URL\"}" - echo "Payload: $payload" - - if [ -z "$token" ]; then - echo "No token provided, skipping GitHub dispatch" - else - echo "Dispatching event to GitHub" - curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $token" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - $url \ - -d "{\"event_type\":\"$event_type\",\"client_payload\":$payload}" || echo "ERROR Failed to dispatch event" >&2 - fi - - if [ $cleanup = true -a $e2e = true ]; then - echo "Delete the cluster $cluster" - ktbx delete --name "$cluster" - else - echo "Cluster $cluster kept for debugging" - fi -} - -trap dispatch EXIT - go install github.com/k8s-school/ciux@"$ciux_version" echo "Ignite the project using ciux" +ciux ignite --selector itest "$src_dir" --suffix "$SUFFIX" + +# Initialize YAML report +home-ci-reporter init "$TEST_REPORT" "fink-broker" # Build step -$src_dir/build.sh -s "$SUFFIX" -i $input_survey -build=true +echo "Phase: Build" +if $src_dir/build.sh -s "$SUFFIX" -i $input_survey; then + home-ci-reporter step "build" "passed" "Build completed successfully" --file "$TEST_REPORT" + build=true +else + home-ci-reporter step "build" "failed" "Build failed" --file "$TEST_REPORT" + exit 1 +fi # e2e tests step cluster=$(ciux get clustername "$src_dir") echo "Delete the cluster $cluster if it already exists" ktbx delete --name "$cluster" || true +echo "Phase: Prerequisites Installation" echo "Create a Kubernetes cluster (Kind), Install OLM and ArgoCD operators." monitoring_opt="" if [ $monitoring = true ] then monitoring_opt="-m" fi -$DIR/prereq-install.sh $monitoring_opt +if $DIR/prereq-install.sh -k "v0.20.0" $monitoring_opt; then + home-ci-reporter step "prereq_install" "passed" "Prerequisites installed successfully" --file "$TEST_REPORT" +else + home-ci-reporter step "prereq_install" "failed" "Prerequisites installation failed" --file "$TEST_REPORT" + exit 1 +fi $(ciux get image --check $src_dir --suffix "$SUFFIX" --env) if [ $CIUX_BUILD = true ]; then kind load docker-image $CIUX_IMAGE_URL --name "$cluster" fi +echo "Phase: ArgoCD Deployment" echo "Run ArgoCD to install the whole fink e2e tests stack" -$DIR/argocd.sh -s "$SUFFIX" -S "$storage" $monitoring_opt +if $DIR/argocd.sh -s "$SUFFIX" -S "$storage" $monitoring_opt; then + home-ci-reporter step "argocd_deploy" "passed" "ArgoCD deployment completed successfully" --file "$TEST_REPORT" +else + home-ci-reporter step "argocd_deploy" "failed" "ArgoCD deployment failed" --file "$TEST_REPORT" + exit 1 +fi +echo "Phase: Test Results Check" echo "Check the results of the tests." -$DIR/check-results.sh -s "$SUFFIX" $monitoring_opt -e2e=true +if $DIR/check-results.sh -s "$SUFFIX" $monitoring_opt; then + home-ci-reporter step "test_check" "passed" "Test results check completed successfully" --file "$TEST_REPORT" + e2e=true +else + home-ci-reporter step "test_check" "failed" "Test results check failed" --file "$TEST_REPORT" + exit 1 +fi +echo "Phase: Image Push" echo "Push the image to Container Registry" -$src_dir/push-image.sh -push=true +if $src_dir/push-image.sh; then + home-ci-reporter step "image_push" "passed" "Image pushed to registry successfully" --file "$TEST_REPORT" + push=true +else + home-ci-reporter step "image_push" "failed" "Image push failed" --file "$TEST_REPORT" + exit 1 +fi + +# Finalize the report +home-ci-reporter finalize --file "$TEST_REPORT" + +# Get final stats for display +END_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +TOTAL_DURATION=$(( $(date -d "$END_TIME" +%s) - $(date -d "$START_TIME" +%s) )) + +echo "==================================" +echo "🎉 FINK E2E TESTS COMPLETED!" +echo "Duration: ${TOTAL_DURATION}s" +echo "Test report: $TEST_REPORT" +echo "==================================" diff --git a/push-image.sh b/push-image.sh index 1e99e8d49..f9a353180 100755 --- a/push-image.sh +++ b/push-image.sh @@ -8,15 +8,11 @@ set -euxo pipefail DIR=$(cd "$(dirname "$0")"; pwd -P) -export CIUXCONFIG=$HOME/.ciux/ciux.build.sh -. "$CIUXCONFIG" - -set -e usage() { cat << EOD -Usage: `basename $0` [options] path host [host ...] +Usage: `basename $0` [options] Available options: -h this message @@ -30,6 +26,8 @@ EOD kind=false registry=true +CIUX_BUILD=${CIUX_BUILD:-""} + # get the options while getopts dhk c ; do case $c in @@ -46,9 +44,28 @@ if [ $# -ne 0 ] ; then exit 2 fi +if [ -z "$CIUX_BUILD" ]; then + CIUXCONFIG=$(ciux get configpath --selector "itest" $DIR) + echo "Sourcing ciux config from $CIUXCONFIG" + . $CIUXCONFIG +fi + if [ $kind = true ]; then kind load docker-image "$CIUX_IMAGE_URL" fi if [ $registry = true ]; then - docker push "$CIUX_IMAGE_URL" + if [ $CIUX_BUILD = true ]; then + echo "Push image $CIUX_PROMOTED_IMAGE_URL to registry" + docker tag "$CIUX_IMAGE_URL" "$CIUX_PROMOTED_IMAGE_URL" + docker push "$CIUX_PROMOTED_IMAGE_URL" + else + if command -v skopeo >/dev/null 2>&1; then + echo "skopeo is already installed" + else + echo "skopeo not available, cannot copy image" + exit 1 + fi + echo "Add image tag $CIUX_PROMOTED_IMAGE_URL to $CIUX_IMAGE_URL" + skopeo copy "docker://$CIUX_IMAGE_URL" "docker://$CIUX_PROMOTED_IMAGE_URL" + fi fi