Adjust workflows to improve automation and use PR template verbiage. (#10995)

* Adjust workflows to improve automation and use PR template verbiage.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Fix reversed package architecture logic.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
This commit is contained in:
Satadru Pramanik, DO, MPH, MEng
2024-12-17 14:39:44 -05:00
committed by GitHub
parent 76f2e9d932
commit 02ce1e95ff
3 changed files with 84 additions and 24 deletions

View File

@@ -273,21 +273,54 @@ jobs:
base_sha: master
files: packages/*.rb
since_last_remote_commit: true
- name: Export variables to github context
- name: Export CHANGED_PACKAGES
run: |
# Convert "packages/foo.rb packages/bar.rb" (from steps.changed-ruby-files.outputs.all_changed_files) into "foo bar"
echo "CHANGED_PACKAGES=$(echo "${{ steps.changed-ruby-files.outputs.all_changed_files }}" | xargs basename -s .rb | xargs)" >> $GITHUB_ENV
- name: Get all changed manifest files
id: changed-manifest-files
uses: tj-actions/changed-files@v45
with:
base_sha: master
files: manifest/**
since_last_remote_commit: true
- name: Create Pull Request
env:
CREW_BRANCH: ${{ github.ref_name }}
TIMESTAMP: ${{ needs.update-check.outputs.output1 }}
CHANGED_MANIFEST_FILES: ${{ steps.changed-ruby-files.outputs.all_changed_files }}
run: |
echo -e "Updated packages:" > /tmp/pr.txt
rm -rf /tmp/pr.txt
echo -e "## Description" >> /tmp/pr.txt
echo -e "- This PR has built package updates using the Build.yml workflow, whichwas pointed to the ${{ github.ref_name }} branch.\n" >> /tmp/pr.txt
echo -e "Updated packages:" >> /tmp/pr.txt
for file in ${CHANGED_PACKAGES}
do
echo "- ${file}" >> /tmp/pr.txt
done
echo -e "##\nBuilds attempted for:" >> /tmp/pr.txt
if [[ "${x86_64_PACKAGES}" == "" ]]; then
echo -e "- [ ] `x86_64`" >> /tmp/pr.txt
else
echo -e "- [x] `x86_64`" >> /tmp/pr.txt
fi
if [[ "${i686_PACKAGES}" == "" ]]; then
echo -e "- [ ] `i686`" >> /tmp/pr.txt
else
echo -e "- [x] `i686`" >> /tmp/pr.txt
fi
if [[ "${armv7l_PACKAGES}" == "" ]]; then
echo -e "- [ ] `armv7l`" >> /tmp/pr.txt
else
echo -e "- [x] `armv7l`" >> /tmp/pr.txt
fi
if [[ "${CHANGED_MANIFEST_FILES}" == "" ]]; then
echo -e "##\n- [x] This PR has no manifest .filelist changes. _(Package changes have neither added nor removed files.)_" >> /tmp/pr.txt
fi
echo -e "##\n### Run the following to get this pull request's changes locally for testing.\n```bash" >> /tmp/pr.txt
echo -e "CREW_REPO=https://github.com/chromebrew/chromebrew.git CREW_BRANCH=${{ github.ref_name }} crew update \\" >> /tmp/pr.txt
echo -e "&& yes | crew upgrade\n```" >> /tmp/pr.txt
cat /tmp/pr.txt
export PR_NUMBER=$(gh pr create --title "AutoBuild: ${{ github.ref_name }} started at ${{ needs.setup.outputs.output1 }}" -F /tmp/pr.txt | rev | cut -d"/" -f1 | rev)
export PR_NUMBER=$(gh pr create --title "AutoBuild: ${{ github.ref_name }} started at ${TIMESTAMP}" -F /tmp/pr.txt | rev | cut -d"/" -f1 | rev)
echo "PR_NUMBER is ${PR_NUMBER}"
echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV
- name: Trigger Unit Test Workflow & Add Reviewer Team

View File

@@ -28,7 +28,10 @@ jobs:
run: |
ruby -Ctools json.rb
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v7
env:
GH_TOKEN: ${{ secrets.CREW_PR_TOKEN }}
with:
add-paths: "tools/repology.json"
title: "Update Repology JSON"
@@ -36,4 +39,12 @@ jobs:
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
commit-message: "Update Repology JSON"
delete-branch: true
team-reviewers: active
team-reviewers: chromebrew/active
- name: Trigger Unit Test Workflow
if: ${{ steps.cpr.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ secrets.CREW_PR_TOKEN }}
PR_NUMBER: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Flipping pr ${PR_NUMBER} state."
gh pr close ${PR_NUMBER} && gh pr reopen ${PR_NUMBER}

View File

@@ -214,35 +214,51 @@ jobs:
clean: false
persist-credentials: true
ref: ${{ needs.update-check.outputs.output2 }}
- name: Get all changed package files
id: changed-ruby-files
uses: tj-actions/changed-files@v45
with:
base_sha: master
files: packages/*.rb
since_last_remote_commit: true
- name: Export variables to github context
run: |
# Convert "packages/foo.rb packages/bar.rb" (from steps.changed-ruby-files.outputs.all_changed_files) into "foo bar"
echo "CHANGED_PACKAGES=$(echo "${{ steps.changed-ruby-files.outputs.all_changed_files }}" | xargs basename -s .rb | xargs)" >> $GITHUB_ENV
- name: Create Pull Request
env:
CREW_BRANCH: ${{ github.ref_name }}
run: |
echo -e "Updated packages:" > /tmp/pr.txt
for file in ${CHANGED_PACKAGES}
do
echo "- ${file}" >> /tmp/pr.txt
done
cat /tmp/pr.txt
export PR_NUMBER=$(gh pr create --title "AutoBuild: ${{ github.ref_name }} started at ${{ needs.setup.outputs.output1 }}" -F /tmp/pr.txt | rev | cut -d"/" -f1 | rev)
echo "PR_NUMBER is ${PR_NUMBER}"
echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV
- name: Create Pull Request
env:
TIMESTAMP: ${{ needs.update-check.outputs.output1 }}
CREW_BRANCH: ${{ needs.update-check.outputs.output2 }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git fetch --shallow-since="1 week"
git diff-tree --no-commit-id --name-only -r $(git rev-parse origin/master)..$(git rev-parse --verify HEAD)
mapfile -t updated_package_array < <( git diff-tree --no-commit-id --name-only -r $(git rev-parse origin/master)..$(git rev-parse --verify HEAD) | grep -v manifest | grep "^packages" | sed -e 's,packages/,,' -e 's,.rb,,')
echo -e "Updated packages:" > /tmp/pr.txt
for file in "${updated_package_array[@]}"
for file in ${CHANGED_PACKAGES}
do
echo "- ${file}" >> /tmp/pr.txt
done
cat /tmp/pr.txt
export PR_NUMBER=$(gh pr create --title "Automatic PR to update packages for ${CREW_BRANCH}" -F /tmp/pr.txt | rev | cut -d"/" -f1 | rev)
export PR_NUMBER=$(gh pr create --title "AutoUpdate: ${{ github.ref_name }} started at ${TIMESTAMP}" -F /tmp/pr.txt | rev | cut -d"/" -f1 | rev)
echo "PR_NUMBER is ${PR_NUMBER}"
echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV
- name: Trigger Unit Test workflow.
run: |
echo "Branch is ${{ needs.update-check.outputs.output2 }}"
gh workflow run "Unit-Test.yml" --ref ${{ needs.update-check.outputs.output2 }}
- name: Add chromebrew/active team reviewers to PR
run: |
${CREW_BRANCH}" -F /tmp/pr.txt | rev | cut -d"/" -f1 | rev)
echo "PR_NUMBER is ${PR_NUMBER}"
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos${{ github.owner }}/${{ github.repository }}/pulls/${PR_NUMBER}/requested_reviewers \
-d '{"team_reviewers":["chromebrew/active"]}'
echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV
- name: Trigger Unit Test Workflow & Add Reviewer Team
env:
GH_TOKEN: ${{ secrets.CREW_PR_TOKEN }}
run: |
echo "Flipping pr ${PR_NUMBER} state."
gh pr close ${PR_NUMBER} && gh pr reopen ${PR_NUMBER}
gh pr edit ${PR_NUMBER} --add-reviewer chromebrew/active