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: improve import path action #2104

Merged
merged 1 commit into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 12 additions & 16 deletions .github/workflows/import_paths.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,17 @@ jobs:
-
name: Run find & replace script
run: ./scripts/replace_import_paths.sh ${{ inputs.version }}
- name: Commit and push changes
uses: devops-infra/action-commit-push@master
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: "auto: update Go import paths to v${{ inputs.version }}"
target_branch: update-paths
- name: Open PR
uses: devops-infra/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
title: ${{ github.event.commits[0].message }}
source_branch: ${{ inputs.source-branch }}
target_branch: ${{ inputs.target-branch }}
assignee: ${{ github.actor }}
draft: true
label: T:auto,T:code-hygiene
token: ${{ secrets.ADD_TO_PROJECT_PAT }}
title: "auto: update Go import paths to v${{ inputs.version }}"
commit-message: "auto: update Go import paths to v${{ inputs.version }}"
body: "**Automated pull request**\n\nUpdating Go import paths to v${{ inputs.version }}"
get_diff: true
base: ${{ inputs.target-branch }}
branch-suffix: random
branch: ${{ inputs.source-branch }}
delete-branch: true
assignees: ${{ github.actor }}
draft: true
labels: T:auto,T:code-hygiene
20 changes: 18 additions & 2 deletions scripts/replace_import_paths.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -euo pipefail

NEXT_MAJOR_VERSION=$1
import_path_to_replace=$(go list -m)

Expand All @@ -15,7 +17,7 @@ replace_paths() {
sed -i "s/github.com\/osmosis-labs\/osmosis\/v${version_to_replace}/github.com\/osmosis-labs\/osmosis\/v${NEXT_MAJOR_VERSION}/g" ${file}
}

# Replace all files within Go packages.
echo "Replacing import paths in Go files"
for mod in $modules;
do
for file in $mod/*; do
Expand All @@ -25,6 +27,20 @@ do
done
done

replace_paths "go.mod"
echo "Replacing import paths in proto files"
for file in $(find proto/osmosis -type f -name "*.proto"); do
replace_paths $file
done

# protocgen.sh
replace_paths "scripts/protocgen.sh"

echo "Updating go.mod and vendoring"
# go.mod
replace_paths "go.mod"
go mod vendor >/dev/null

echo "running make proto-gen"
# ensure protos match generated Go files
# N.B.: This must be run after go mod vendor.
make proto-gen >/dev/null