RussellSpitzer commented on code in PR #2156: URL: https://github.com/apache/polaris/pull/2156#discussion_r2260609903
########## releasey/test/test-04-build-and-test.sh: ########## @@ -0,0 +1,101 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# +# Test Script for 04-build-and-test.sh +# +# Tests the dry-run functionality of the build and test script by verifying the +# exact commands that would be executed. It does not do much given that the +# script only run a single gradle command and interacts with Github to validate +# the state of the commit. +# + +set -euo pipefail + +test_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +releasey_dir=$(cd "${test_dir}/.." && pwd) +LIBS_DIR="${releasey_dir}/libs" + +source "${LIBS_DIR}/_log.sh" +source "${LIBS_DIR}/_constants.sh" +source "${LIBS_DIR}/_version.sh" + +function usage() { + cat <<EOF +$(basename "$0") [--help | -h] + + Tests the 04-build-and-test.sh script by running it in dry-run mode + and verifying the commands that would be executed. + + Options: + -h --help + Print usage information. + + Examples: + $(basename "$0") + +EOF +} + +while [[ $# -gt 0 ]]; do + case $1 in + --help | -h) + usage + exit 0 + ;; + *) + print_error "Unknown option/argument $1" + usage >&2 + exit 1 + ;; + esac +done + +print_info "Starting test for 04-build-and-test.sh..." + +print_info "Create temporary file to capture the commands that would be executed..." +temp_file=$(mktemp) +trap 'rm -f "$temp_file"' EXIT + +print_info "Running script..." +# Set a dummy GitHub token for testing to avoid API calls +DRY_RUN=1 GITHUB_TOKEN="dummy_token" \ + "${releasey_dir}/04-build-and-test.sh" \ + 3>"$temp_file" + +print_info "Verifying output content..." +# Read the actual content +actual_content=$(cat "$temp_file") + +expected_content="cd ${releasey_dir}/.. +./gradlew clean build +curl -s -H \"Authorization: Bearer dummy_token\" -H \"Accept: application/vnd.github+json\" -H \"X-GitHub-Api-Version: 2022-11-28\" https://api.github.com/repos/apache/polaris/commits/$(git rev-parse HEAD)/check-runs | jq -r '[.check_runs[].conclusion | select(. != \"success\" and . != \"skipped\")] | length'" + +# Compare content +if [[ "$actual_content" == "$expected_content" ]]; then Review Comment: could probably extract this out into a function since it's used in all the regressions if you like -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org