mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
<!--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.-->
71 lines
1.6 KiB
Bash
Executable File
71 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 create API state snapshots used to validate releases are not breaking backwards compatibility.
|
|
|
|
usage() {
|
|
echo "Usage: $0"
|
|
echo
|
|
echo "-d Dry-run mode. No project files will not be modified. Default: 'false'"
|
|
echo "-p Package to generate API state snapshot of. Default: ''"
|
|
echo "-o Output directory where state will be written to. Default: './internal/data/apidiff'"
|
|
exit 1
|
|
}
|
|
|
|
dry_run=false
|
|
package=""
|
|
output_dir="./internal/data/apidiff"
|
|
repo_toplevel="$( git rev-parse --show-toplevel )"
|
|
tools_mod_file="${repo_toplevel}/internal/tools/go.mod"
|
|
|
|
while getopts "dp:o:" o; do
|
|
case "${o}" in
|
|
d)
|
|
dry_run=true
|
|
;;
|
|
p)
|
|
package=$OPTARG
|
|
;;
|
|
o)
|
|
output_dir=$OPTARG
|
|
;;
|
|
*)
|
|
usage
|
|
;;
|
|
esac
|
|
done
|
|
shift $((OPTIND-1))
|
|
|
|
if [ -z "$package" ]; then
|
|
usage
|
|
fi
|
|
|
|
set -ex
|
|
|
|
# Create temp dir for generated files.
|
|
# Source: https://unix.stackexchange.com/a/84980
|
|
tmp_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'apidiff')
|
|
clean_up() {
|
|
ARG=$?
|
|
if [ $dry_run = true ]; then
|
|
echo "Dry-run complete. Generated files can be found in $tmp_dir"
|
|
else
|
|
rm -rf "$tmp_dir"
|
|
fi
|
|
exit $ARG
|
|
}
|
|
trap clean_up EXIT
|
|
|
|
mkdir -p "$tmp_dir/$package"
|
|
|
|
go tool -modfile "${tools_mod_file}" apidiff -w "$tmp_dir"/"$package"/apidiff.state "$package"
|
|
|
|
# Copy files if not in dry-run mode.
|
|
if [ $dry_run = false ]; then
|
|
mkdir -p "$output_dir/$package" && \
|
|
cp "$tmp_dir/$package/apidiff.state" \
|
|
"$output_dir/$package"
|
|
fi
|