-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only the WSL-Pro-Service needs to stay up-to-date. And we only need to update modules when these have changed
- Loading branch information
1 parent
f411abe
commit 26f7e99
Showing
3 changed files
with
34 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 27 additions & 22 deletions
49
.github/actions/update-workspace-dependencies/update-workspace-dependencies.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
cd ${TARGET_MODULE} | ||
current_commit=$(git rev-parse HEAD~0) | ||
|
||
# Find internal dependencies | ||
repo="github.com/${GITHUB_REPOSITORY}" | ||
url="${repo}/${TARGET_MODULE}" | ||
regex="s#${url} \(${repo}/[^@]\+@v.*\)#\1#p" | ||
dependencies=`go mod graph | sed -n "${regex}"` | ||
|
||
# Gather all go modules | ||
modules=$(go work edit -json \ | ||
| jq -r '.Use | keys[] as $k | "\(.[$k].DiskPath)"' \ | ||
| sed $'s#\.\/##' \ | ||
) | ||
for dependency in ${dependencies}; do | ||
pattern="^${repo}/\(.*\)@v\([^-]\+\)-\([^-]\+\)-\(.*\)$" | ||
# Capture groups: (https://go.dev/ref/mod#versions) | ||
# \1 Dependency path | ||
# \2 Base version prefix | ||
# \3 Timestamp | ||
# \4 Revision identifier (12-character prefix of the commit hash) | ||
|
||
# Find internal dependencies | ||
for mod in ${modules} ; do | ||
cd "${mod}" | ||
echo "::group::Updating module ${mod}::" | ||
dep_path=`echo $dependency | sed "s#${pattern}#\1#"` | ||
dep_commit=`echo $dependency | sed "s#${pattern}#\4#"` | ||
|
||
url="${repo}/${mod}" | ||
regex="s#${url} \(${repo}/[^@]\+\)@v.*#\1#p" | ||
dependencies=`go mod graph | sed -n "${regex}"` | ||
|
||
for dep in ${dependencies}; do | ||
go get "${dep}@main" | ||
done | ||
diff_files="$(git diff --name-only ${dep_commit} -- "../${dep_path}")" | ||
if [ -z "${diff_files}" ] ; then | ||
continue | ||
fi | ||
|
||
echo "::group::Updating dependency ${dep_path}::" | ||
|
||
echo "Files changed since commit ${dep_commit}:" | ||
echo "${diff_files}" | ||
|
||
go get "${repo}/${dep_path}@${current_commit}" | ||
|
||
go mod tidy | ||
|
||
echo "Done" | ||
echo "::endgroup::" | ||
cd ~- | ||
done | ||
|
||
go work sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters