Skip to content

Commit

Permalink
ci: add compat check 052 x main (#21174)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Aug 7, 2024
1 parent 5b7d8b6 commit cc25f59
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/scripts/check-compat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

if [ $# -lt 3 ]; then
echo "Usage: check-compat.sh <branch> <simapp_version> [<go_mod_name1> <go_mod_name2> ...]"
exit 1
fi

dir="tmp"
branch=$1
simapp_version=$2
shift 3
go_mod_names=("$@")

# clone cosmos-sdk
export FILTER_BRANCH_SQUELCH_WARNING=1
git clone -b $branch --depth 1 https://github.com/cosmos/cosmos-sdk $dir

# save last commit branch commit
COMMIT=$(git rev-parse HEAD)
# save the last main commit
latest_commit=$(git ls-remote https://github.com/cosmos/cosmos-sdk.git refs/heads/main | cut -f1 || "main")

# if simapp_version is v2 then use simapp/v2
if [ $simapp_version == "v2" ]; then
cd $dir/simapp/v2
else
cd $dir/simapp
fi

# bump all cosmos-sdk packages to latest branch commit
VERSIONS=$(go mod edit -json | jq -r '.Replace[].Old.Path')

# Initialize variables for different types of replaces
BRANCH_REPLACES=""
MAIN_REPLACES=""
REQUIRES=""

for version in $VERSIONS; do
if [[ " ${go_mod_names[@]} " =~ " ${version} " ]]; then
MAIN_REPLACES+=" -replace $version=$version@$latest_commit"
continue
elif [[ $version == "github.com/cosmos/cosmos-sdk"* || $version == "cosmossdk.io/"* ]]; then
BRANCH_REPLACES+=" -replace $version=$version@$COMMIT"
fi
done

for mod in ${go_mod_names[@]}; do
REQUIRES+=" -require $mod@$latest_commit"
done

# Apply the replaces
go mod edit $BRANCH_REPLACES $MAIN_REPLACES $REQUIRES

go mod tidy

# Test SimApp
go test -mod=readonly -v ./...
75 changes: 75 additions & 0 deletions .github/workflows/software-compat-v052.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: SimApp (v2) v0.52 Integration with Main
on:
push:
branches:
- main
workflow_dispatch:
jobs:
compat:
name: Software Compat
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/scripts/check-compat.sh
sparse-checkout-cone-mode: false
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
check-latest: true
- name: Test v052 with latest main
run: |
.github/scripts/check-compat.sh $BRANCH $SIMAPP_VERSION cosmossdk.io/runtime/v2 cosmossdk.io/server/v2 cosmossdk.io/store/v2 cosmossdk.io/server/v2/stf cosmossdk.io/server/v2/appmanager cosmossdk.io/api cosmossdk.io/store cosmossdk.io/core cosmossdk.io/core/testing
env:
BRANCH: release/v0.52.x
SIMAPP_VERSION: v1
- name: Test v052 v2 with latest main
run: |
.github/scripts/check-compat.sh $BRANCH $SIMAPP_VERSION cosmossdk.io/runtime/v2 cosmossdk.io/server/v2 cosmossdk.io/store/v2 cosmossdk.io/server/v2/stf cosmossdk.io/server/v2/appmanager cosmossdk.io/api cosmossdk.io/store cosmossdk.io/core cosmossdk.io/core/testing
env:
BRANCH: release/v0.52.x
SIMAPP_VERSION: v2
sims-notify-success:
needs: [compat]
runs-on: ubuntu-latest
if: ${{ success() }}
steps:
- uses: actions/checkout@v4
- name: Get previous workflow status
uses: ./.github/actions/last-workflow-status
id: last_status
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Notify Slack on success
if: ${{ steps.last_status.outputs.last_status == 'failure' }}
uses: rtCamp/action-slack-notify@v2.3.0
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: sdk-sims
SLACK_USERNAME: release/v0.52.x x main compat
SLACK_ICON_EMOJI: ":white_check_mark:"
SLACK_COLOR: good
SLACK_MESSAGE: Latest main x v0.52.x is compatible
SLACK_FOOTER: ""

sims-notify-failure:
permissions:
contents: none
needs: [compat]
runs-on: ubuntu-latest
if: ${{ failure() }}
steps:
- name: Notify Slack on failure
uses: rtCamp/action-slack-notify@v2.3.0
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: sdk-sims
SLACK_USERNAME: release/v0.52.x x main compat
SLACK_ICON_EMOJI: ":skull:"
SLACK_COLOR: danger
SLACK_MESSAGE: Latest main x v0.52.x is breaking
SLACK_FOOTER: ""

0 comments on commit cc25f59

Please sign in to comment.