Skip to content
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

Getting those runners going to update Cosmos for the three images, and also check for any build updates to automate #23165

Closed
wants to merge 10 commits into from
42 changes: 42 additions & 0 deletions .github/workflows/Cosmo.Mac.Ubuntu.Window.go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Go

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build-and-test:
strategy:
matrix:
os: [ubuntu-24.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5.2.0
with:
go-version: '1.20' # You can specify a version range or use 'stable' if you want the latest stable version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Update Go version to latest stable

Given the current date (January 2025), Go 1.20 is outdated. Consider using a more recent version for security updates and performance improvements.

-        go-version: '1.20'  # You can specify a version range or use 'stable' if you want the latest stable version
+        go-version: '1.22'  # Latest stable version as of January 2025
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
go-version: '1.20' # You can specify a version range or use 'stable' if you want the latest stable version
go-version: '1.22' # Latest stable version as of January 2025

cache: true
cache-dependency-path: go.sum

- name: Fetch Latest Cosmos SDK Version
run: |
# Fetch the latest release tag from GitHub
LATEST_VERSION=$(curl -s "https://api.github.com/repos/cosmos/cosmos-sdk/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
echo "Latest Cosmos SDK version: $LATEST_VERSION"
echo "COSMOS_VERSION=$LATEST_VERSION" >> $GITHUB_ENV

Comment on lines +26 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for curl command and improve version extraction

The current implementation lacks error handling for the curl command and uses complex sed parsing which might break. Consider using jq for more reliable JSON parsing.

-        LATEST_VERSION=$(curl -s "https://api.github.com/repos/cosmos/cosmos-sdk/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
-        echo "Latest Cosmos SDK version: $LATEST_VERSION"
-        echo "COSMOS_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
+        if ! RESPONSE=$(curl -sf "https://api.github.com/repos/cosmos/cosmos-sdk/releases/latest"); then
+            echo "Failed to fetch latest Cosmos SDK version"
+            exit 1
+        fi
+        LATEST_VERSION=$(echo "$RESPONSE" | jq -r .tag_name)
+        if [[ -n "$LATEST_VERSION" ]]; then
+            echo "Latest Cosmos SDK version: $LATEST_VERSION"
+            echo "COSMOS_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
+        else
+            echo "Failed to extract version from response"
+            exit 1
+        fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: |
# Fetch the latest release tag from GitHub
LATEST_VERSION=$(curl -s "https://api.github.com/repos/cosmos/cosmos-sdk/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
echo "Latest Cosmos SDK version: $LATEST_VERSION"
echo "COSMOS_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
run: |
# Fetch the latest release tag from GitHub
if ! RESPONSE=$(curl -sf "https://api.github.com/repos/cosmos/cosmos-sdk/releases/latest"); then
echo "Failed to fetch latest Cosmos SDK version"
exit 1
fi
LATEST_VERSION=$(echo "$RESPONSE" | jq -r .tag_name)
if [[ -n "$LATEST_VERSION" ]]; then
echo "Latest Cosmos SDK version: $LATEST_VERSION"
echo "COSMOS_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
else
echo "Failed to extract version from response"
exit 1
fi
🧰 Tools
🪛 actionlint (1.7.4)

26-26: shellcheck reported issue in this script: SC2086:info:4:42: Double quote to prevent globbing and word splitting

(shellcheck)

- name: Update Go Modules
run: |
# Update go.mod with the latest Cosmos SDK version
go get github.com/cosmos/cosmos-sdk@${{ env.COSMOS_VERSION }}
go mod tidy

Comment on lines +34 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for go get command

The module update steps lack error handling which could lead to silent failures.

-        go get github.com/cosmos/cosmos-sdk@${{ env.COSMOS_VERSION }}
-        go mod tidy
+        if ! go get github.com/cosmos/cosmos-sdk@${{ env.COSMOS_VERSION }}; then
+            echo "Failed to update Cosmos SDK"
+            exit 1
+        fi
+        if ! go mod tidy; then
+            echo "Failed to tidy modules"
+            exit 1
+        fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Update go.mod with the latest Cosmos SDK version
go get github.com/cosmos/cosmos-sdk@${{ env.COSMOS_VERSION }}
go mod tidy
# Update go.mod with the latest Cosmos SDK version
if ! go get github.com/cosmos/cosmos-sdk@${{ env.COSMOS_VERSION }}; then
echo "Failed to update Cosmos SDK"
exit 1
fi
if ! go mod tidy; then
echo "Failed to tidy modules"
exit 1
fi

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
Loading
Loading