Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
auricom committed Sep 23, 2024
1 parent 6c3db24 commit b3a2438
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 22 deletions.
66 changes: 48 additions & 18 deletions .github/scripts/update-go-dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

set -oue pipefail
set -x

COSMOSSDK_BRANCH=${COSMOSSDK_BRANCH:-refs/heads/release/v0.50.x}

Expand Down Expand Up @@ -30,17 +31,38 @@ get_and_update_module() {
local commit=$1
pseudo_version=$(get_pseudo_version "$module" "$commit")

if [ $? -ne 0 ]; then
echo "Error occurred while getting pseudo-version for $module" >&2
exit 1
fi

echo "Updating $module to pseudo-version $pseudo_version"

go mod edit -replace=$module=$module@$pseudo_version

# if ! go mod download $module@$pseudo_version; then
# return 1
# fi

return 0
}

# Function to check if current module is replaced by a local path
check_replaced_local() {
go mod edit --json | jq -e --arg v "$module" '
(.Replace[] | select(.Old.Path | contains($v)) | .Old.Path + " => " + .New.Path) as $output
| $output
| if test("../") then
0
else
error("No ../ found in output")
end
' > /dev/null 2>&1

if [ $? -ne 0 ]; then
return 1
else
return 0
fi
}


# Extract module paths and versions from go.mod on current folder
modules=$(go mod edit --json | jq -r '.Require[] | select(.Path | contains("/")) | .Path')

Expand All @@ -54,25 +76,33 @@ for module in $modules; do

echo "module: $module"

# Checking cosmos-sdk modules
if [[ $module =~ "cosmossdk.io" ]]; then
# Force specific modules to HEAD of main instead of release
if [[ $module =~ "depinject" ]] || [[ $module =~ "log" ]] || [[ $module =~ "math" ]]; then
if ! get_and_update_module "$latest_commit_main"; then
echo "Failed to update module $module after trying main."
exit 1
# Checking if module is not already replaced with local path
if ! check_replaced_local; then

# Checking cosmos-sdk modules
if [[ $module =~ "cosmossdk.io" ]]; then

# Force specific modules to HEAD of main instead of release
modules_exceptions=("depinject" "log" "math" "core/testing" "schema")
if [[ " ${modules[*]} " =~ " ${module} " ]]; then
if ! get_and_update_module "$latest_commit_main"; then
echo "Failed to update module $module after trying main."
exit 1
fi
else
if ! get_and_update_module "$latest_commit_branch"; then
echo "Failed to update module $module after trying $COSMOSSDK_BRANCH."
fi
fi
else
elif [[ $module == "github.com/cosmos/cosmos-sdk" ]]; then
# modules that need to follow HEAD on release branch
if ! get_and_update_module "$latest_commit_branch"; then
echo "Failed to update module $module after trying $COSMOSSDK_BRANCH."
exit 1
fi
fi
elif [[ $module == "github.com/cosmos/cosmos-sdk" ]]; then
# modules that need to follow HEAD on release branch
if ! get_and_update_module "$latest_commit_branch"; then
echo "Failed to update module $module after trying $COSMOSSDK_BRANCH."
exit 1
fi
else
echo "module $module is already replaced by local path"
fi
done

Expand Down
60 changes: 56 additions & 4 deletions .github/workflows/nightly-1-release-cosmos-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
schedule:
- cron: 0 0 * * * # Every day at 0:00 UTC
workflow_dispatch:
pull_request:


permissions:
packages: write
Expand All @@ -22,6 +24,50 @@ concurrency:
cancel-in-progress: true

jobs:
update-dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: cosmos/ibc-go
ref: main
token: ${{ github.token }}
path: ibc-go

- uses: actions/checkout@v4
with:
path: nightly-stack

- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true

- name: Update cosmos-sdk modules to HEAD/main
run: |
cd ibc-go/simapp
../../nightly-stack/.github/scripts/update-go-dependencies.sh
- name: show output of modified go.sum and go.mod
run: |
echo "############"
echo "# go.mod"
echo "############"
cat ibc-go/simapp/go.mod
echo -e "\n\n"
echo "############"
echo "# go.mod"
echo "############"
cat ibc-go/simapp/go.sum
- name: Upload go.mod and go.sum
uses: actions/upload-artifact@v4
with:
name: go-files
path: |
ibc-go/simapp/go.mod
ibc-go/simapp/go.sum
build-cosmos-sdk:
runs-on: ubuntu-latest
outputs:
Expand All @@ -38,11 +84,21 @@ jobs:
token: ${{ github.token }}
path: cosmos-sdk

- uses: actions/checkout@v4
with:
path: nightly-stack

- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true

- name: Download go.mod and go.sum
uses: actions/download-artifact@v4
with:
name: go-files
path: cosmos-sdk/simapp

- name: Create application binary
id: build
run: |
Expand Down Expand Up @@ -142,10 +198,6 @@ jobs:
echo "image_name=${image_name}" >> $GITHUB_OUTPUT
echo "outputs=${outputs}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
path: nightly-stack

- uses: actions/download-artifact@v4
with:
name: ${{ env.RELEASE_NAME }}-${{ matrix.major-version }}-${{ env.date }}-${{ matrix.go-arch }}
Expand Down

0 comments on commit b3a2438

Please sign in to comment.