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 427d227
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 47 deletions.
120 changes: 89 additions & 31 deletions .github/scripts/update-go-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -oue pipefail

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

# Function to get the latest commit SHA for a given repo and branch
get_latest_commit() {
Expand Down Expand Up @@ -30,50 +30,108 @@ 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
}

# Extract module paths and versions from go.mod on current folder
modules=$(go mod edit --json | jq -r '.Require[] | select(.Path | contains("/")) | .Path')
# 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))) as $replacement
| if $replacement.New.Path | contains("../") then
0
else
error("No ../ found in the New.Path")
end
' > /dev/null 2>&1

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

## VARIABLES

# github.com/cosmos/cosmos-sdk branch to follow
COSMOSSDK_BRANCH=${COSMOSSDK_BRANCH:-refs/heads/release/v0.50.x}
# github.com/cometbft/cometbft branch to follow
COMETBFT_BRANCH=${COMETBFT_BRANCH:-main}

latest_commit_main=$(get_latest_commit "cosmos/cosmos-sdk" "main")
echo "cosmos/cosmos-sdk main latest_commit: $latest_commit_main"
latest_commit_branch=$(get_latest_commit "cosmos/cosmos-sdk" "$COSMOSSDK_BRANCH")
echo "cosmos/cosmos-sdk $COSMOSSDK_BRANCH latest_commit: $latest_commit_branch"
## INTERNAL VARIABLES

### Commits
cosmossdk_latest_commit_main=$(get_latest_commit "cosmos/cosmos-sdk" "main")
echo "cosmos/cosmos-sdk main latest_commit: $cosmossdk_latest_commit_main"
cosmossdk_latest_commit_branch=$(get_latest_commit "cosmos/cosmos-sdk" "$COSMOSSDK_BRANCH")
echo "cosmos/cosmos-sdk $COSMOSSDK_BRANCH latest_commit: $cosmossdk_latest_commit_branch"
cometbft_latest_commit_branch=$(get_latest_commit "cometbft/cometbft" "$COMETBFT_BRANCH")
echo "cometbft/cometbft $COMETBFT_BRANCH latest_commit: $cometbft_latest_commit_branch"

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

# Parse every module in go.mod, and update dependencies according to logic
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
fi
else
if ! get_and_update_module "$latest_commit_branch"; then
echo "Failed to update module $module after trying $COSMOSSDK_BRANCH."
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
fi
# Checking cosmos-sdk modules
case "$module" in
*cosmossdk.io*)
case "$module" in
# Force specific modules to HEAD of main instead of release
*core/testing*|*depinject*|*log*|*math*|*schema*)
if ! get_and_update_module "$cosmossdk_latest_commit_main"; then
echo "Failed to update module $module after trying main."
exit 1
fi
;;
*)
# Checking if module is not already replaced with local path
if ! check_replaced_local; then

if ! get_and_update_module "$cosmossdk_latest_commit_branch"; then
echo "Failed to update module $module after trying $COSMOSSDK_BRANCH."
fi
else
echo "module $module is already replaced by local path"
fi
;;
esac
;;
*github.com/cosmos/cosmos-sdk*)

# Checking if module is not already replaced with local path
if ! check_replaced_local; then

# modules that need to follow HEAD on release branch
if ! get_and_update_module "$cosmossdk_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
;;
*github.com/cometbft/cometbft*)
# Exclude cometbft/cometbft-db from logic
if [[ ! "$module" =~ "cometbft-db" ]]; then
if ! get_and_update_module "$cometbft_latest_commit_branch"; then
echo "Failed to update module $module after trying main."
exit 1
fi
fi
esac
done

go mod verify
Expand Down
76 changes: 67 additions & 9 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,8 +24,56 @@ concurrency:
cancel-in-progress: true

jobs:
build-cosmos-sdk:
update-dependencies-cosmossdk:
runs-on: ubuntu-latest
strategy:
matrix:
major-version: [v0.50.x, v0.52.x]
steps:
- uses: actions/checkout@v4
with:
repository: cosmos/cosmos-sdk
ref: main
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: Update cosmos-sdk modules to HEAD/main
run: |
cd cosmos-sdk/simapp
COSMOSSDK_BRANCH=refs/heads/release/${{ matrix.major-version }} ../../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 cosmos-sdk/simapp/go.mod
echo -e "\n\n"
echo "############"
echo "# go.mod"
echo "############"
cat cosmos-sdk/simapp/go.sum
- name: Upload go.mod and go.sum
uses: actions/upload-artifact@v4
with:
name: go-files-${{ matrix.major-version }}
path: |
cosmos-sdk/simapp/go.mod
cosmos-sdk/simapp/go.sum
build-cosmossdk:
runs-on: ubuntu-latest
needs: update-dependencies-cosmossdk
outputs:
date: ${{ steps.archive.outputs.date }}
strategy:
Expand All @@ -38,15 +88,27 @@ 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-${{ matrix.major-version }}
path: cosmos-sdk/simapp

- name: Create application binary
id: build
run: |
cd cosmos-sdk
cd cosmos-sdk/simapp
go mod tidy
cd ../
GOARCH=${{ matrix.go-arch }} make install
echo "gobin=$(go env GOPATH)/bin" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -142,10 +204,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 Expand Up @@ -207,7 +265,7 @@ jobs:
merge:
name: Merge cosmos-sdk
runs-on: ubuntu-latest
needs: [build-cosmos-sdk]
needs: [build-cosmossdk]
if: ${{ always() }}
strategy:
matrix:
Expand Down Expand Up @@ -294,7 +352,7 @@ jobs:
shell: bash
run: exit 1

sims-notify-success:
build-cosmossdk-notify-success:
needs: merge
runs-on: ubuntu-latest
if: ${{ success() }}
Expand All @@ -318,7 +376,7 @@ jobs:
SLACK_MESSAGE: ${{ env.RELEASE_NAME }} is passing
SLACK_FOOTER: ""

sims-notify-failure:
build-cosmossdk-notify-failure:
permissions:
contents: none
needs: merge
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/nightly-2-test-cosmos-sdk-comet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ concurrency:
cancel-in-progress: true

jobs:
build-cosmos-sdk-comet:
build-cosmossdk-comet:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -92,8 +92,8 @@ jobs:
sleep 3
done
build-cosmos-sdk-comet-notify-success:
needs: build-cosmos-sdk-comet
build-cosmossdk-comet-notify-success:
needs: build-cosmossdk-comet
runs-on: ubuntu-latest
if: ${{ success() }}
steps:
Expand All @@ -116,7 +116,7 @@ jobs:
SLACK_MESSAGE: ${{ env.RELEASE_NAME }} is passing
SLACK_FOOTER: ""

build-cosmos-sdk-comet-notify-failure:
build-cosmossdk-comet-notify-failure:
permissions:
contents: none
needs: build-cosmos-sdk-comet
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/nightly-3-release-ibc-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ concurrency:

jobs:

update-dependencies:
update-dependencies-ibc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
build-ibc:
runs-on: ubuntu-latest
needs: update-dependencies
needs: update-dependencies-ibc
outputs:
date: ${{ steps.archive.outputs.date }}
strategy:
Expand Down Expand Up @@ -104,7 +104,9 @@ jobs:
- name: Create application binary
id: build
run: |
cd ibc-go
cd ibc-go/simapp
go mod tidy
cd ..
GOARCH=${{ matrix.go-arch }} make build
echo "gobin=$(go env GOPATH)/bin" >> $GITHUB_OUTPUT
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This repository contains the nightly builds of the Interchain Stack. The Interch
- Dependencies:
- cosmos-sdk release/v0.50.x
- cosmos-sdk release/v0.52.x
- cometbft main
- Outputs:
- Workflow artifacts
- Container image
Expand Down

0 comments on commit 427d227

Please sign in to comment.