Files
Marin Atanasov NikolovandGitHub 33d97c1468 feat: migrate to tools directive (v2) (#13906)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

This PR is a continuation of PR #13844 , which had to be reverted in
#13899, because of an issue with the `apidiff` tool as described in
#13897 .

On top of the changes initially proposed in #13844, this PR also adds
the [gomodTidy option to renovate
postUpdateOptions](https://docs.renovatebot.com/configuration-options/),
so that module dependencies are properly updated before new changes are
proposed by `renovate`.

The changes from this PR have been applied to my fork, so that I can
confirm that all workflows are passing as expected and a couple of dummy
PRs can be seen below.

- https://github.com/dnaeon/opentelemetry-collector/pull/4 (a dummy
change to ensure workflows are running fine)
- https://github.com/dnaeon/opentelemetry-collector/pull/5 (a PR made by
`renovate` which takes care of updating a Go tool)

cc: @mx-psi , @dmathieu , @codeboten 

P.S.: Sorry for the troubles caused by the initial PR!

#### Link to tracking issue
Fixes #13897

<!--Describe what testing was performed and which tests were added.-->
#### Testing

Local testing as well as testing with PRs against my fork (see links in
the description for sample PRs and workflow runs)

<!--Describe the documentation added.-->
#### Documentation

N/A
<!--Please delete paragraphs that you did not use before submitting.-->
2025-10-08 17:12:30 +00:00

61 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
# This script is used to compare API state snapshots to the current package state in order to validate releases are not breaking backwards compatibility.
usage() {
echo "Usage: $0"
echo
echo "-c Check-incompatibility mode. Script will fail if an incompatible change is found. Default: 'false'"
echo "-p Package to generate API state snapshot of. Default: ''"
echo "-d directory where prior states will be read from. Default: './internal/data/apidiff'"
exit 1
}
package=""
input_dir="./internal/data/apidiff"
check_only=false
repo_toplevel="$( git rev-parse --show-toplevel )"
tools_mod_file="${repo_toplevel}/internal/tools/go.mod"
while getopts "cp:d:" o; do
case "${o}" in
c)
check_only=true
;;
p)
package=$OPTARG
;;
d)
input_dir=$OPTARG
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "$package" ]; then
usage
fi
set -e
if [ -e "$input_dir"/"$package"/apidiff.state ]; then
changes=$(go tool -modfile "${tools_mod_file}" apidiff "$input_dir"/"$package"/apidiff.state "$package")
if [ -n "$changes" ] && [ "$changes" != " " ]; then
SUB='Incompatible changes:'
if [ $check_only = true ] && [[ "$changes" =~ .*"$SUB".* ]]; then
echo "Incompatible Changes Found."
echo "Check the logs in the GitHub Action log group: 'Compare-States'."
exit 1
else
echo "Changes found in $package:"
echo "$changes"
fi
fi
fi