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: add relevant commits in diff #3741

Merged
merged 1 commit into from
Dec 22, 2023
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
26 changes: 26 additions & 0 deletions ci/apps/tasks/open-charts-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git checkout ${ref}
app_src_files=($(buck2 uquery 'inputs(deps("'"//apps/${APP}:"'"))' 2>/dev/null))

relevant_commits=()
for commit in $(git log --format="%H" ${old_ref}..${ref}); do
changed_files=$(git diff-tree --no-commit-id --name-only -r $commit)

for file in ${changed_files[@]}; do
if [[ " ${app_src_files[*]} " == *"$file"* ]]; then
relevant_commits+=($commit)
break
fi
done
done

# create a branch from the old state and commit the new state of the app
set +e
git fetch origin ${APP}-${old_ref}
Expand All @@ -56,6 +68,9 @@ for file in "${app_src_files[@]}"; do
git checkout "$ref" -- "$file"
done

echo "${relevant_commits[@]}" > relevant_commits.json
git add relevant_commits.json

git commit -m "Commit state of \`${APP}\` at \`${ref}\`" --allow-empty
git push -fu origin ${APP}-${ref}

Expand All @@ -66,6 +81,17 @@ Code diff contained in this image:
${github_url}/compare/${APP}-${old_ref}...${APP}-${ref}
Relevant commits:
EOF

for commit in "${relevant_commits[@]}"; do
cat <<EOF >> ../body.md
- ${github_url}/commit/${commit}
EOF
done

cat <<EOF >> ../body.md
The ${APP} image will be bumped to digest:
\`\`\`
${digest}
Expand Down
27 changes: 27 additions & 0 deletions ci/tasks/open-charts-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git checkout ${ref}
app_src_files=($(buck2 uquery 'inputs(deps("//core/..."))' 2>/dev/null))

relevant_commits=()
for commit in $(git log --format="%H" ${old_ref}..${ref}); do
changed_files=$(git diff-tree --no-commit-id --name-only -r $commit)

for file in ${changed_files[@]}; do
if [[ " ${app_src_files[*]} " == *"$file"* ]]; then
relevant_commits+=($commit)
break
fi
done
done

# create a branch from the old state and commit the new state of core
set +e
git fetch origin core-${old_ref}
Expand All @@ -57,6 +69,10 @@ for file in "${app_src_files[@]}"; do
git checkout "$ref" -- "$file"
done

# put the relevant commits as a json array in a file
echo "${relevant_commits[@]}" > relevant_commits.json
git add relevant_commits.json

git commit -m "Commit state of \`core\` at \`${ref}\`" --allow-empty
git push -fu origin core-${ref}

Expand All @@ -67,6 +83,17 @@ Code diff contained in this image:

${github_url}/compare/core-${old_ref}...core-${ref}

Relevant commits:
EOF

for commit in "${relevant_commits[@]}"; do
cat <<EOF >> ../body.md
- ${github_url}/commit/${commit}
EOF
done

cat <<EOF >> ../body.md

The galoy api image will be bumped to digest:
\`\`\`
${digest}
Expand Down
Loading