babylonlabs-io / finality-gadget

Other
6 stars 4 forks source link

ensure the changes in this FG repo will not break FP e2e tests #2

Open bap2pecs opened 3 months ago

bap2pecs commented 3 months ago

@bap2pecs cloned issue babylonchain/babylon-finality-gadget#52 on 2024-07-09:

Summary

We want to ensure that changes here will still work with the FP repo, but the problem is that the e2e tests are in the FP repository.

We are currently getting the commit hash in this repo and locally updated it in the cloned FP repository. Then we run e2e tests manually in the FP repo

But imagine having to do this every time we make a PR in this repo—it's tedious. So, a proposed solution is to rely on the CI in this repo.

how it works should be first we clone the FP repository and get the commit hash of the PR here. then replace the dependency in the FP repository and run go mod tidy, and then run e2e tests

Tasks

  • [ ] create CI job to clone FP repo, fetch commit hash of the current PR

  • [ ] replace the deps in the FP repo and run go mod tidy

  • [ ] run FP e2e tests

bap2pecs commented 3 days ago

I have this in my .bashrc that might be useful:

# only works if the git remote URL is using `ssh`
 get_go_mod_version() {
     # Get the current commit hash
     local current_hash=$(git rev-parse HEAD)

     # Get the remote origin URLa
     local remote_url=$(git remote get-url origin)

     # Extract the repository path from the remote URL
     if [[ $remote_url == https://* ]]; then
         # For HTTPS URLs
         repo_path=$(echo $remote_url | sed -E 's|https://github.com/(.+)\.git|\1|')
     else
         # For SSH URLs
         repo_path=$(echo $remote_url | sed -E 's/.*:(.+)\.git/\1/')
     fi

     # Construct and execute the go list command
     go list -m github.com/$repo_path@$current_hash
 }

example usage

git clone git@github.com:babylonlabs-io/finality-provider.git
git checkout base/consumer-chain-support
godep_nocp

then you will see

github.com/babylonlabs-io/finality-provider v0.5.1-0.20241024124619-7d341b5d02e3

now you can copy it to the go.mod file where you need to use this specific FP version