Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: manual job for updating in-repo go mods; ci to warn if files changed #4667

Merged
merged 50 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
c37cdc0
add suggested change
pysel Mar 19, 2023
f53a8e8
check for valid branch
pysel Mar 19, 2023
f4f5242
change-wip
pysel Mar 19, 2023
1ba42eb
debugging
pysel Mar 19, 2023
1ff2e7d
wip
pysel Mar 19, 2023
8aec7ad
debugging
pysel Mar 19, 2023
904fc59
debugging
pysel Mar 19, 2023
090f535
debugging
pysel Mar 19, 2023
6013733
debugging
pysel Mar 19, 2023
471e41e
debugging
pysel Mar 19, 2023
924ed38
debugging
pysel Mar 19, 2023
41e196e
debugging
pysel Mar 19, 2023
cab1ce6
remove change in osmoutils
pysel Mar 19, 2023
eb3d27b
Update .github/workflows/go-mod-auto-bump.yml
pysel Mar 19, 2023
4196482
Update .github/workflows/go-mod-auto-bump.yml
pysel Mar 19, 2023
f2fa444
change
pysel Mar 19, 2023
336fb5e
remove debug echos
pysel Mar 19, 2023
d5692f1
docs: correctly name a step
pysel Mar 19, 2023
c73e0fb
change
pysel Mar 19, 2023
c97473b
change osmoutils
pysel Mar 19, 2023
c8920f6
add token
pysel Mar 20, 2023
d01ac06
git diff with latest main commit
pysel Mar 20, 2023
13f6a62
remove echo
pysel Mar 20, 2023
ba08f32
remove osmoutils changes
pysel Mar 20, 2023
e8dffce
improve docs
pysel Mar 20, 2023
9ce57a0
remove main branch from triggers
pysel Mar 21, 2023
a38da34
fix bug: running on wrong branch
pysel Mar 21, 2023
3f4cfed
remove legacy conditions
pysel Mar 21, 2023
3b44f6b
PAT
pysel Mar 21, 2023
85d7517
v3 checkout
pysel Mar 21, 2023
760c82b
osmoutils change
pysel Mar 22, 2023
5caed1b
bring back script
pysel Mar 30, 2023
18ae83c
change
pysel Mar 30, 2023
a3dca57
config
pysel Mar 30, 2023
49f01d2
change
pysel Mar 30, 2023
9cdbab1
better commit message + try w/o token
pysel Mar 30, 2023
1ade2fd
change
pysel Mar 30, 2023
fd88a9a
bring back token
pysel Mar 30, 2023
c7e8761
change
pysel Mar 30, 2023
65de06c
remove osmoutils change
pysel Apr 1, 2023
30e0d2f
only commit+push changes when they were added
pysel Apr 1, 2023
7c0ac87
change
pysel Apr 1, 2023
0c8d06d
nit
pysel Apr 1, 2023
8d8799a
reset change
pysel Apr 1, 2023
c83c874
tidy and changelog
faddat May 7, 2023
83d4656
restore go.modsum
pysel May 12, 2023
63cf2ab
better CHANGELOG
pysel May 12, 2023
ddbbe46
use mod/sum from main
pysel Jul 6, 2023
e3dbdaa
make manual
p0mvn Aug 28, 2023
1552c1e
Update CHANGELOG.md
p0mvn Aug 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/go-mod-auto-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This workflow is used in order to automatically update go.mod in case one of:
# * osmoutils
# * osmomath
# * x/ibc-hooks
# * x/epochs
# is updated.
# It is triggerred by a manual workflow:
# https://github.com/osmosis/osmosis/actions/workflows/go-mod-auto-bump.yml

name: Go Mod Auto Version Update
on:
workflow_dispatch:
inputs:
target-branch:
description: 'Target Branch'
default: ''
required: true
permissions:
contents: write

jobs:
update_go_mod:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set GH config
run: |
git config user.email "[email protected]"
git config user.name "github-actions"

# Setup Go
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '>=1.19.0'
- name: Fetch branches and checkout target
run: |
git fetch origin ${{ inputs.target-branch }}
git checkout ${{ inputs.target-branch }}
git fetch origin main

- name: Get latest commit on main branch
id: main_commit
run: |
echo "LATEST_MAIN_COMMIT=$(git rev-parse main)" >> $GITHUB_OUTPUT

- name: Run script
run: |
COMMIT_AFTER_PUSH=${{ github.event.after }}
bash ./scripts/update-go-mod.sh ${{ steps.main_commit.outputs.LATEST_MAIN_COMMIT }} $COMMIT_AFTER_PUSH

- name: Add Changes
id: add_changes
run: |
git add .
echo ANY_CHANGES_ADDED=$(git diff --name-only --cached) >> $GITHUB_OUTPUT

- name: Commit and Push Changes
if: ${{ steps.add_changes.outputs.ANY_CHANGES_ADDED != '' }}
run: |
git commit -m "Auto: update go.mod after push to ${{ inputs.target-branch }} that modified dependencies locally"
git push origin ${{ inputs.target-branch }}
60 changes: 60 additions & 0 deletions .github/workflows/go-mod-auto-update-instructions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Workflow: Go Mod Auto-Update Instructions
#
# Guides contributors when changes are made to our in-repo Go modules.
# Links the manual GitHub action to run that updates the Go mods.
#
# Triggers:
# - Pull Request Opened, Synchronized, Reopened
#
# Secrets:
# GITHUB_TOKEN: Created automatically by GitHub, used for commenting on the PR

name: Go Mod Auto-Update Instructions

on:
pull_request:
types:
- opened
- synchronize
- reopened
paths:
- 'osmomath/**'
- 'osmoutils/**'
- 'x/ibc-hooks/**'
- 'x/epochs/**'

permissions:
pull-requests: write

jobs:
comment:
runs-on: ubuntu-latest
steps:
-
name: Checkout code
uses: actions/checkout@v3
-
name: Comment on PR
uses: thollander/actions-comment-pull-request@v2
with:
message: |
**Important Notice**

This PR modifies an in-repo Go module. It is one of:
- osmomath
- osmoutils
- x/ibc-hooks
- x/epochs

The dependent Go modules, especially the root one, will have to be
updated to reflect the changes. Failing to do so might cause e2e to fail.

Please follow the instructions below:

1. Open https://github.com/osmosis/osmosis/actions/workflows/go-mod-auto-bump.yml
2. Provide the current branch name
3. On success, confirm if an automated commit corretly updated the go.mod and go.sum files

Please let us know if you need any help.
mode: upsert
comment_tag: instructions
70 changes: 70 additions & 0 deletions scripts/update-go-mod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

# Script for checking `git diff` between two commits and updating osmoutils, osmomath, epochs or ibc-hooks if any were changed between two commits
# Used by Go Mod Auto Version Update workflow
# First argument: sha of a first commit
# Second argument: sha of a second commit

is_updated() {
if [ "${1}" != "" ]
then
return 1
fi
return 0
}

commit_before=$1
commit_after=$2

changed_osmoutils=$(git diff --name-only $commit_before $commit_after | grep osmoutils)
changed_osmomath=$(git diff --name-only $commit_before $commit_after | grep osmomath)
changed_ibc_hooks=$(git diff --name-only $commit_before $commit_after | grep x/ibc-hooks)
changed_epochs=$(git diff --name-only $commit_before $commit_after | grep x/epochs)

is_updated $changed_osmoutils
update_osmoutils=$?

is_updated $changed_osmomath
update_osmomath=$?

is_updated $changed_ibc_hooks
update_ibc_hooks=$?

is_updated $changed_epochs
update_epochs=$?

if [ $update_osmoutils -eq 1 ]
then
go get github.com/osmosis-labs/osmosis/osmoutils@$commit_after

# x/epochs depends on osmoutils
cd x/epochs
go get github.com/osmosis-labs/osmosis/osmoutils@$commit_after
go mod tidy

# x/ibc-hooks depends on osmoutils
cd ../ibc-hooks
go get github.com/osmosis-labs/osmosis/osmoutils@$commit_after
go mod tidy

# return to root
cd ../..
fi

if [ $update_osmomath -eq 1 ]
then
go get github.com/osmosis-labs/osmosis/osmomath@$commit_after
fi

if [ $update_ibc_hooks -eq 1 ]
then
go get github.com/osmosis-labs/osmosis/x/ibc-hooks@$commit_after
fi

if [ $update_epochs -eq 1 ]
then
go get github.com/osmosis-labs/osmosis/x/epochs@$commit_after
fi

go mod tidy
go work sync