Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
104 changes: 104 additions & 0 deletions bin/check-package-years.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/bin/bash

# Copyright 2026 Google LLC
#
# Licensed 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
#
# https://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.

# This script ensures that all the headers in any given folder under packages
# all have the same Copyright year in their header.

# Get the directory where the script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Assume packages is a sibling of the bin directory where this script lives
# or in the current directory if run from root.
if [ -d "$SCRIPT_DIR/../packages" ]; then
PACKAGES_DIR="$SCRIPT_DIR/../packages"
elif [ -d "$SCRIPT_DIR/packages" ]; then
PACKAGES_DIR="$SCRIPT_DIR/packages"
else
echo "Error: Could not find 'packages' directory."
exit 1
fi

EXIT_CODE=0

# Iterate through each package folder
# Using find -print0 and read -d '' is the most robust way to handle any filename
while IFS= read -r -d '' pkg_path; do
pkg=$(basename "$pkg_path")
echo "Scanning package $pkg..."

first_year=""
first_file=""

# Find all files that are likely to have copyright headers
# This addresses the request to ensure all files in the folder have a copyright year.
# We focus on source files to avoid checking every single file (like images, etc.)
# and exclude common non-source files.

# Use a temporary file to store the list of files to avoid subshell issues
tmp_file=$(mktemp)
find "$pkg_path" -type f \
\( -name "*.ts" -o -name "*.js" -o -name "*.proto" \) \
-not -path "*/node_modules/*" \
-not -path "*/.git/*" \
-not -path "*/dist/*" \
-not -path "*/build/*" \
-not -name "LICENSE" \
-not -name "CHANGELOG.md" \
-not -name "package.json" \
-not -name "package-lock.json" \
-not -name "pnpm-lock.yaml" \
-not -name "prettier.config.js" \
-not -name ".prettierrc.js" \
-not -name ".eslintrc.js" \
-not -name "webpack.config.js" \
-not -name "rollup.config.js" \
> "$tmp_file"

while IFS= read -r file; do
if [ -z "$file" ]; then continue; fi

# Extract the year from the first copyright line found in the file
# We use grep -i to be case-insensitive and || true to be robust
year=$(grep -iohE "Copyright [0-9]{4}" "$file" | head -n 1 | awk '{print $2}' || true)

if [ -z "$year" ]; then
# If the file is missing a copyright year, report it
# Note: We only report this if it's a file type we expect to have it
echo "Error: Missing copyright year in file: $file"
EXIT_CODE=1
continue
fi

if [ -z "$first_year" ]; then
first_year="$year"
first_file="$file"
elif [ "$year" != "$first_year" ]; then
echo "Error: Copyright year mismatch in package: $pkg"
echo " $first_file: $first_year"
echo " $file: $year"
EXIT_CODE=1
# We don't break here to allow finding all issues in this package
fi
done < "$tmp_file"
rm "$tmp_file"
done < <(find "$PACKAGES_DIR" -maxdepth 1 -mindepth 1 -type d -print0 | sort -z)

if [ $EXIT_CODE -eq 0 ]; then
echo "Success: All package copyright years match."
else
echo "Failure: Some packages have mismatched or missing copyright years."
fi

exit $EXIT_CODE
2 changes: 1 addition & 1 deletion bin/delete-everything-split-repo.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2022 Google LLC
# Copyright 202 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions bin/generate-readme.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function downloadRepoMetadata () {

let meta;
for (const urlandRepo of urlsAndRepos) {
try {
try {
const res = await github.request({ url: urlandRepo.url });
meta = JSON.parse(
Buffer.from(res.data.content, 'base64').toString('utf8')
Expand Down Expand Up @@ -156,7 +156,7 @@ async function processMetadata (repoMetadata) {
if (!supportDocsUrl.match(/^https/)) {
supportDocsUrl = `https://${supportDocsUrl}`
}

let res;
let remoteUrlExists = true;
// if URL doesn't exist, fall back to the generic docs page
Expand Down
4 changes: 2 additions & 2 deletions bin/migrate-git-history.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ then
if [[ $file == "${KEEP_FILES_SPACES[$LAST_ELEMENT]}" ]]
then
KEEP_FILE_COMMANDS+="git checkout -- ${file} 2>/dev/null || true"
else
else
KEEP_FILE_COMMANDS+="git checkout -- ${file} 2>/dev/null || true; "
fi
fi
done
# restore files to keep, silence errors if the file doesn't exist
FILTER="${FILTER}; ${KEEP_FILE_COMMANDS}"
Expand Down
14 changes: 7 additions & 7 deletions bin/migrate-split-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
# 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.

set -e

if [ $# -lt 2 ]
then
echo "Usage: $0 <split-repo-name> <target-path>"
exit 1
fi

# repo name (e.g. nodejs-asset)
export SPLIT_REPO=$1
# destination directory (e.g. packages/google-cloud-asset)
export PACKAGE_PATH="$2"

## Get the directory of the build script
SCRIPT_DIR=$(realpath $(dirname "${BASH_SOURCE[0]}"))

export UPDATE_SCRIPT="${SCRIPT_DIR}/split-repo-post-process.sh"
# run the migrate script, remove .kokoro and .github folders
# keep the .github/.OwlBot.yaml config
Expand All @@ -39,6 +39,6 @@ ${SCRIPT_DIR}/migrate-git-history.sh \
"${PACKAGE_PATH}" \
"samples",".github/workflows/ci.yaml,.github/workflows/issues-no-repro.yaml,.github/workflows/response.yaml,SECURITY.md,renovate.json" \
"samples/generated",".github/.OwlBot.yaml,system-test/test/quickstart.js,system-test/test/quickstart.test.js"


${SCRIPT_DIR}/update-readme-only-split-repo.sh "${SPLIT_REPO}" "${ARTIFACT_NAME}"

${SCRIPT_DIR}/update-readme-only-split-repo.sh "${SPLIT_REPO}" "${ARTIFACT_NAME}"
36 changes: 18 additions & 18 deletions bin/split-repo-post-process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# 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.

set -e

# find owner from lower-level CODEOWNERS and add to top-level CODEOWNERS
Expand Down Expand Up @@ -41,13 +41,13 @@ if [[ -d "${PACKAGE_PATH}/.github/workflows" ]]; then
fi
fi


PACKAGE_NAME=$(basename ${PACKAGE_PATH})

echo "Detecting the latest version in ${PACKAGE_PATH}"
LATEST_VERSION=$(cat "${PACKAGE_PATH}/package.json" | jq -r ".version")
echo "Latest version: ${LATEST_VERSION}"

echo "Adding release-please config"
# Determine which config file to use
if [[ "${PACKAGE_PATH}" == packages/* ]]; then
Expand All @@ -59,21 +59,21 @@ fi
# using a temp file because jq doesn't like writing to the input file as it reads
cat "${CONFIG_FILE}" | jq --sort-keys ". * {\"packages\": {\"${PACKAGE_PATH}\": {}}}" > "${CONFIG_FILE}.tmp"
mv "${CONFIG_FILE}.tmp" "${CONFIG_FILE}"

echo "Adding release-please manifest version"
# using a temp file because jq doesn't like writing to the input file as it reads
cat .release-please-manifest.json | jq --sort-keys ". * {\"${PACKAGE_PATH}\": \"${LATEST_VERSION}\"}" > .release-please-manifest2.json
mv .release-please-manifest2.json .release-please-manifest.json

echo "Moving ${PACKAGE_PATH}/.github/.OwlBot.yaml"
mv "${PACKAGE_PATH}/.github/.OwlBot.yaml" "${PACKAGE_PATH}/.OwlBot.yaml"

echo "Fixing format of ${PACKAGE_PATH}/.OwlBot.yaml"
# remove `docker:` line
gsed -i "/docker:/d" "${PACKAGE_PATH}/.OwlBot.yaml"
# remove `image:` line
gsed -i "/image:/d" "${PACKAGE_PATH}/.OwlBot.yaml"

if grep -q "/owl-bot-staging/\$1/\$2" "${PACKAGE_PATH}/.OwlBot.yaml"
then
echo "OwlBot config is copying each folder"
Expand All @@ -82,15 +82,15 @@ then
else
gsed -i "s/dest: \/owl-bot-staging/dest: \/owl-bot-staging\/${PACKAGE_NAME}/" "${PACKAGE_PATH}/.OwlBot.yaml"
fi

echo "fixing owlbot.py file"

if test -f "${PACKAGE_PATH}/owlbot.py"; then
gsed -i "s/import synthtool.languages.node as node/import synthtool.languages.node_mono_repo as node/" "${PACKAGE_PATH}/owlbot.py"
echo gsed -i "s/node.owlbot_main(/node.owlbot_main(relative_dir=${PACKAGE_PATH},/" "${PACKAGE_PATH}/owlbot.py"
gsed -i "s|node.owlbot_main(|node.owlbot_main(relative_dir=\"${PACKAGE_PATH}\",|" "${PACKAGE_PATH}/owlbot.py"
fi

# update .repo and .issue_tracker in .repo-metadata.json
echo "Update .repo-metadata.json"
echo "updating .repo to googleapis/google-cloud-node"
Expand All @@ -102,17 +102,17 @@ then
jq ".issue_tracker = \"https://github.com/googleapis/google-cloud-node/issues\"" "${PACKAGE_PATH}/.repo-metadata.json" > "${PACKAGE_PATH}/.repo-metadata2.json"
mv "${PACKAGE_PATH}/.repo-metadata2.json" "${PACKAGE_PATH}/.repo-metadata.json"
fi

echo "updating repository object type"
# using a temp file because jq doesn't like writing to the input file as it reads
jq -r ".repository = {\"type\": \"git\", \"directory\": \"${PACKAGE_PATH}\", \"url\": \"https://github.com/googleapis/google-cloud-node.git\"}" ${PACKAGE_PATH}/package.json > ${PACKAGE_PATH}/package2.json
mv ${PACKAGE_PATH}/package2.json ${PACKAGE_PATH}/package.json

echo "updating homepage"
# using a temp file because jq doesn't like writing to the input file as it reads
jq -r ".homepage = \"https://github.com/googleapis/google-cloud-node/tree/main/${PACKAGE_PATH}\"" ${PACKAGE_PATH}/package.json > ${PACKAGE_PATH}/package2.json
mv ${PACKAGE_PATH}/package2.json ${PACKAGE_PATH}/package.json


# remove .github folder from package
if [[ -d "${PACKAGE_PATH}/.github" ]]; then
Expand All @@ -137,7 +137,7 @@ fi
# If migrated package uses kokoro, inject diff check
if [ -d "${PACKAGE_PATH}/.kokoro" ]; then
echo "Found .kokoro directory. Injecting conditional test logic."

TRAMPOLINE_SCRIPT=""
if [ -f "${PACKAGE_PATH}/.kokoro/trampoline_v2.sh" ]; then
TRAMPOLINE_SCRIPT="${PACKAGE_PATH}/.kokoro/trampoline_v2.sh"
Expand All @@ -160,9 +160,9 @@ if [ -d "${PACKAGE_PATH}/.kokoro" ]; then
if [[ "\${RUNNING_IN_CI:-}" == "true" ]]; then
# The package path is hardcoded during migration
RELATIVE_PKG_PATH="${PACKAGE_PATH}"

echo "Checking for changes in \${RELATIVE_PKG_PATH}..."

# Determine the diff range based on the CI system/event
# Safe default: HEAD~1..HEAD
DIFF_RANGE="HEAD~1..HEAD"
Expand Down Expand Up @@ -192,7 +192,7 @@ fi

echo "Fixing .trampolinerc for populate-secrets.sh"
gsed -i 's|source ${PROJECT_ROOT}/.kokoro/populate-secrets.sh|source ${PROJECT_ROOT}/'"${PACKAGE_PATH}"'/.kokoro/populate-secrets.sh|' "${PACKAGE_PATH}"/.trampolinerc

# add changes to local git directory
git add .
git commit -am "build: add release-please config, fix owlbot-config"
2 changes: 1 addition & 1 deletion bin/update-readme-only-split-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ else
hub pull-request -m "build: update README for deprecation notice"
fi

rm -rf "/tmp/${SPLIT_REPO}"
rm -rf "/tmp/${SPLIT_REPO}"
2 changes: 1 addition & 1 deletion core/common/.OwlBot.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions core/common/owlbot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 Google LLC.
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -19,4 +19,4 @@

common_templates = gcp.CommonTemplates()
templates = common_templates.node_mono_repo_library(relative_dir="core/common")
s.copy(templates, destination="core/common", excludes=["README.md"])
s.copy(templates, destination="core/common", excludes=["README.md"])
2 changes: 1 addition & 1 deletion core/dev-packages/jsdoc-fresh/owlbot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion core/dev-packages/jsdoc-region-tag/owlbot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion core/dev-packages/pack-n-play/owlbot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion core/paginator/.OwlBot.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion handwritten/bigquery-storage/owlbot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion handwritten/bigquery/owlbot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion handwritten/bigtable/.OwlBot.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
3 changes: 1 addition & 2 deletions handwritten/bigtable/.kokoro/lint.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion handwritten/logging-bunyan/owlbot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 Google LLC.
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion handwritten/logging/src/v2/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Google LLC
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Loading
Loading