dannycjones commented on code in PR #3084: URL: https://github.com/apache/iceberg-rust/pull/3084#discussion_r3872826488
########## dev/check_license_notice.sh: ########## @@ -0,0 +1,159 @@ +#!/usr/bin/env 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. + +# Every distributed artifact must ship its own LICENSE and NOTICE. +# Checking the packaged file list, rather than the crate directory, +# also catches files that exist on disk but are excluded from the published +# crate. + +set -Eeuo pipefail + +REQUIRED_FILES=(LICENSE NOTICE) + +usage() { + cat <<USAGE +Usage: + $0 [-h|--help] + +Checks that every publishable crate in the workspace packages a top-level +LICENSE and NOTICE file, as required for Apache source and binary releases. +USAGE +} + +require_command() { + local command_name="$1" + if ! command -v "${command_name}" >/dev/null 2>&1; then + echo "This script requires '${command_name}', but it is not installed." >&2 + return 1 + fi +} + +report_error() { + # GitHub Actions turns `::error::` lines into annotations on the job summary. + if [ "${GITHUB_ACTIONS:-}" = "true" ]; then + echo "::error::$1" + else + echo "ERROR: $1" >&2 + fi +} + +# Return name and manifest path for every crate that would be published in a release. +publishable_crates() { + # `publish` is an empty list for `publish = false` crates and null when the + # crate may be published to any registry. + cargo metadata --no-deps --format-version 1 | + jq -r '.packages[] | select(.publish != []) | "\(.name)\t\(.manifest_path)"' +} + +# Check file exists, following any symlinks. +check_file_exists() { + local path="$1" + + # `-s` follows symlinks + if [ ! -s "${path}" ]; then + return 1 + fi +} + +# Return true if the given path (second arg) is present in the list of paths (first arg). +packages_file_at_root() { + local packaged_paths="$1" + local file_name="$2" + + local packaged_path + + while IFS= read -r packaged_path; do + if [ "${packaged_path}" = "${file_name}" ]; then + return 0 + fi + done <<<"${packaged_paths}" + + return 1 +} + +# Verify that the necessary files are bundled in the crate. +# Accepts both crate name and its directory, so that artifacts can be fully verified including symlink resolution. +check_crate() { + local crate="$1" + local crate_dir="$2" + + local packaged_paths status repo_path + status=0 + + echo "Checking ${crate}..." + packaged_paths="$(cargo package --package "${crate}" --list --locked)" Review Comment: `--list` actually implies it, but we can add anyway. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
