From b3a2438222600d90c981f3fc9ef144c6b75de8e2 Mon Sep 17 00:00:00 2001 From: auricom <27022259+auricom@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:38:39 +0200 Subject: [PATCH] wip --- .github/scripts/update-go-dependencies.sh | 66 ++++++++++++++----- .../nightly-1-release-cosmos-sdk.yaml | 60 +++++++++++++++-- 2 files changed, 104 insertions(+), 22 deletions(-) diff --git a/.github/scripts/update-go-dependencies.sh b/.github/scripts/update-go-dependencies.sh index a9ac24f..04b1d35 100755 --- a/.github/scripts/update-go-dependencies.sh +++ b/.github/scripts/update-go-dependencies.sh @@ -1,6 +1,7 @@ #!/bin/bash set -oue pipefail +set -x COSMOSSDK_BRANCH=${COSMOSSDK_BRANCH:-refs/heads/release/v0.50.x} @@ -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') @@ -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 diff --git a/.github/workflows/nightly-1-release-cosmos-sdk.yaml b/.github/workflows/nightly-1-release-cosmos-sdk.yaml index bf85464..72e8195 100644 --- a/.github/workflows/nightly-1-release-cosmos-sdk.yaml +++ b/.github/workflows/nightly-1-release-cosmos-sdk.yaml @@ -9,6 +9,8 @@ on: schedule: - cron: 0 0 * * * # Every day at 0:00 UTC workflow_dispatch: + pull_request: + permissions: packages: write @@ -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: @@ -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: | @@ -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 }}