diff --git a/.github/scripts/update-go-dependencies.sh b/.github/scripts/update-go-dependencies.sh index a9ac24f..858bde7 100755 --- a/.github/scripts/update-go-dependencies.sh +++ b/.github/scripts/update-go-dependencies.sh @@ -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() { @@ -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 diff --git a/.github/workflows/nightly-1-release-cosmos-sdk.yaml b/.github/workflows/nightly-1-release-cosmos-sdk.yaml index bf85464..5cee2bc 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,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: @@ -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 @@ -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 }} @@ -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: @@ -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() }} @@ -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 diff --git a/.github/workflows/nightly-2-test-cosmos-sdk-comet.yml b/.github/workflows/nightly-2-test-cosmos-sdk-comet.yml index d939b22..96236b7 100644 --- a/.github/workflows/nightly-2-test-cosmos-sdk-comet.yml +++ b/.github/workflows/nightly-2-test-cosmos-sdk-comet.yml @@ -19,7 +19,7 @@ concurrency: cancel-in-progress: true jobs: - build-cosmos-sdk-comet: + build-cosmossdk-comet: runs-on: ubuntu-latest strategy: matrix: @@ -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: @@ -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 diff --git a/.github/workflows/nightly-3-release-ibc-go.yml b/.github/workflows/nightly-3-release-ibc-go.yml index 35ddcd9..349e888 100644 --- a/.github/workflows/nightly-3-release-ibc-go.yml +++ b/.github/workflows/nightly-3-release-ibc-go.yml @@ -26,7 +26,7 @@ concurrency: jobs: - update-dependencies: + update-dependencies-ibc: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -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: @@ -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 diff --git a/README.md b/README.md index aa00c43..965d418 100644 --- a/README.md +++ b/README.md @@ -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