-
Notifications
You must be signed in to change notification settings - Fork 37
Monitoring and release pipeline #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5a856ad
Adding meta data for monitoring packages
sanojsubran a9f565a
Added script for monitoring and updating packages
sanojsubran 4283adf
Added github action for monitoring and updating
sanojsubran 7529487
Updated github workflow for version monitoring and updation.
sanojsubran de96ccc
Updated script not to create a duplicate PR if one already exists for…
sanojsubran dafb9e1
Scheduling the job to run at 4am on a daily basis
sanojsubran 603bc5f
Refactored the monitoring script
sanojsubran fed7c66
Changed the title of Github Action
sanojsubran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Auto instrumentation for version updates | ||
run-name: Running job for checking newer packages and updating instrumentation | ||
on: | ||
schedule: | ||
- cron: '0 4 * * *' | ||
jobs: | ||
monitor-update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install package | ||
run: | | ||
sudo apt-get -y install jq | ||
|
||
- uses: actions/checkout@v3 | ||
name: Checkout repo | ||
with: | ||
fetch-depth: 0 | ||
ssh-key: ${{secrets.PRIVATE_KEY_GO_TRACER_RELEASE}} | ||
|
||
- name: Run script to monitor packages and create PR with updated changes | ||
id: verison_updater | ||
run: ./version_updater.sh | ||
shell: bash {0} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,3 +117,9 @@ See the [`instaamqp` package documentation][godoc] for detailed examples. | |
[godoc]: https://pkg.go.dev/github.com/instana/go-sensor/instrumentation/instaamqp | ||
[instaamqp.WrapChannel]: https://pkg.go.dev/github.com/instana/go-sensor/instrumentation/instaamqp#WrapChannel | ||
[amqp.Channel]: https://pkg.go.dev/github.com/streadway/[email protected]#Channel | ||
|
||
<!--- | ||
Mandatory comment section for CI/CD !! | ||
target-pkg-url: github.com/streadway/amqp | ||
current-version: v1.0.0 | ||
---> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
#!/bin/bash | ||
|
||
# (c) Copyright IBM Corp. 2023 | ||
|
||
# ---------------------------------------------------------------------- # | ||
# Script to monitor the packages and update the instrumentation packages # | ||
# ---------------------------------------------------------------------- # | ||
|
||
# Function to extract the package url and current version from the metadata | ||
extract_info_from_markdown() { | ||
if [ -e "$1" ]; then | ||
local markdown_text=$(<"$1") | ||
# Extract target-package-url and current-version using awk | ||
TARGET_PKG_URL=$(echo "$markdown_text" | awk -F: '/target-pkg-url:/ {print $2}' | tr -d '[:space:]') | ||
CURRENT_VERSION=$(echo "$markdown_text" | awk -F: '/current-version:/ {print $2}' | tr -d '[:space:]') | ||
else | ||
echo "Error: File not found - $1" | ||
TARGET_PKG_URL="" | ||
CURRENT_VERSION="" | ||
fi | ||
} | ||
|
||
# Function to query the latest released version of the package | ||
find_latest_version() { | ||
local pkg=$1 | ||
if [ -n "$pkg" ]; then | ||
# Query the latest version for the package | ||
local url="https://proxy.golang.org/${pkg}/@latest" | ||
LATEST_VERSION=$(curl -s "$url" | jq .Version | tr -d '"') | ||
else | ||
LATEST_VERSION="" | ||
echo "Invalid package location: $pkg" | ||
fi | ||
|
||
} | ||
|
||
# Function to compare versions | ||
version_compare() { | ||
local version1=$1 | ||
local version2=$2 | ||
|
||
local major_version1=$(echo "$version1" | sed -E 's/v([0-9]+)\.([0-9]+)\..*/\1/') | ||
local minor_version1=$(echo "$version1" | sed -E 's/v([0-9]+)\.([0-9]+)\..*/\2/') | ||
local major_version2=$(echo "$version2" | sed -E 's/v([0-9]+)\.([0-9]+)\..*/\1/') | ||
local minor_version2=$(echo "$version2" | sed -E 's/v([0-9]+)\.([0-9]+)\..*/\2/') | ||
|
||
# We are checking the changes in minor versions for automation purpose | ||
if [ "$major_version1" = "$major_version2" ] && [ "$minor_version1" -gt "$minor_version2" ]; then | ||
echo "true" | ||
else | ||
echo "false" | ||
fi | ||
} | ||
|
||
# Function to update the metadata with the latest version information | ||
replace_version_in_file() { | ||
local version=$1 | ||
local file_path=$2 | ||
|
||
# Read the content of the file | ||
local file_content=$(<"$file_path") | ||
|
||
# Replace current-version with the new version | ||
# shellcheck disable=SC2001 | ||
local updated_content=$(echo "$file_content" | sed "s/current-version: [^ ]*/current-version: $version/") | ||
|
||
# Write the updated content back to the file | ||
echo "$updated_content" > "$file_path" | ||
echo "Version in file $file_path updated to $version" | ||
} | ||
|
||
DIRECTORY_PATH=$(pwd)/instrumentation | ||
echo "$DIRECTORY_PATH" | ||
|
||
if [ -d "$DIRECTORY_PATH" ]; then | ||
for folder in "$DIRECTORY_PATH"/*/; do | ||
# Create a branch and commit the changes | ||
git config user.name "IBM/Instana/Team Go" | ||
git config user.email "[email protected]" | ||
|
||
git checkout main | ||
|
||
INSTRUMENTATION=$(basename "$folder") | ||
# Identify the path to the README file | ||
README_PATH="${folder}README.md" | ||
|
||
echo "--------------$INSTRUMENTATION-----------------" | ||
if [ ! -e "$README_PATH" ]; then | ||
continue | ||
fi | ||
|
||
# Extract the metadata from the README file | ||
extract_info_from_markdown "$README_PATH" | ||
|
||
if [ -z "$TARGET_PKG_URL" ]; then | ||
continue | ||
fi | ||
|
||
# Print the extracted values | ||
#echo "Target Package URL: $TARGET_PKG_URL" | ||
echo "Current Version: $CURRENT_VERSION" | ||
|
||
# Find the latest version of the instrumented package | ||
find_latest_version "$TARGET_PKG_URL" | ||
echo "Latest version:" "$LATEST_VERSION" | ||
|
||
version_compare "$LATEST_VERSION" "$CURRENT_VERSION" | ||
update_needed=$( version_compare "$LATEST_VERSION" "$CURRENT_VERSION" ) | ||
|
||
if [ "$update_needed" != true ]; then | ||
continue | ||
fi | ||
|
||
if gh pr list | grep -q "instrumentation $INSTRUMENTATION for new version $LATEST_VERSION"; then | ||
echo "PR for $INSTRUMENTATION newer version:$LATEST_VERSION already exists. Skipping to next iteration" | ||
continue | ||
fi | ||
|
||
echo "Update needed for this package. Update process starting..." | ||
cd "$folder" || continue | ||
go get "$TARGET_PKG_URL" | ||
go mod tidy | ||
go test ./... || echo "Continuing the operation even if the test fails. This needs manual intervention" | ||
|
||
|
||
# Need to update the current version in the README file | ||
replace_version_in_file "$LATEST_VERSION" "$README_PATH" | ||
|
||
CURRENT_TIME_UNIX=$(date '+%s') | ||
git checkout -b "update-instrumentations-$INSTRUMENTATION-id-$CURRENT_TIME_UNIX" | ||
|
||
git add go.mod go.sum README.md | ||
git commit -m "Updated go.mod, go.sum files, README.md for $INSTRUMENTATION" | ||
git push origin @ | ||
|
||
# Create a PR request for the changes | ||
# shellcheck disable=SC2046 | ||
gh pr create --title "Updating instrumentation $INSTRUMENTATION for new version $LATEST_VERSION. Id: $CURRENT_TIME_UNIX" \ | ||
--body "This PR adds changes for the newer version $LATEST_VERSION for the instrumented package" --head $(git branch --show-current) | ||
|
||
done | ||
else | ||
echo "Error: The specified path is not a directory." | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.