| 1 |
name: PR AutoFix |
| 2 |
on: [push] |
| 3 |
permissions: {} |
| 4 |
jobs: |
| 5 |
PRAutoFix: |
| 6 |
permissions: |
| 7 |
actions: write # to cancel/stop running workflows (styfle/cancel-workflow-action) |
| 8 |
contents: write # to create branch (peter-evans/create-pull-request) |
| 9 |
pull-requests: write # to create a PR (peter-evans/create-pull-request) |
| 10 |
|
| 11 |
runs-on: ubuntu-latest |
| 12 |
steps: |
| 13 |
# Cache bazel build |
| 14 |
- name: Get current time |
| 15 |
uses: srfrnk/current-time@master |
| 16 |
id: current-time |
| 17 |
with: |
| 18 |
format: YYYYWW |
| 19 |
- name: Get current time |
| 20 |
uses: srfrnk/current-time@master |
| 21 |
id: current-time-with-day |
| 22 |
with: |
| 23 |
format: YYYYWWd |
| 24 |
- name: Cache bazel |
| 25 |
uses: actions/cache@v3 |
| 26 |
env: |
| 27 |
cache-name: bazel-cache |
| 28 |
with: |
| 29 |
path: ~/.cache/bazel |
| 30 |
# formattedTime here is like 2021323 - the year concatenated with the week then |
| 31 |
# the day of that week. |
| 32 |
# As this changes every day, we cycle to a new cache once per day, with lookup |
| 33 |
# across the week (and then the year). |
| 34 |
key: ${{ runner.os }}-${{ steps.current-time-with-day.outputs.formattedTime }} |
| 35 |
restore-keys: | |
| 36 |
${{ runner.os }}-${{ steps.current-time.outputs.formattedTime }} |
| 37 |
${{ runner.os }}- |
| 38 |
# Cancel current runs if they're still running |
| 39 |
# (saves processing on fast pushes) |
| 40 |
- name: Cancel Previous Runs |
| 41 |
uses: styfle/[email protected] |
| 42 |
with: |
| 43 |
access_token: ${{ github.token }} |
| 44 |
# Allow opt-out for some users |
| 45 |
- name: Should I Stay Or Should I Go |
| 46 |
uses: actions/github-script@v4 |
| 47 |
id: check |
| 48 |
with: |
| 49 |
script: | |
| 50 |
// If you'd like not to run this code on your commits, add your github user id here: |
| 51 |
NO_AUTOFIX_USERS = [] |
| 52 |
const { owner, repo } = context.repo |
| 53 |
if (NO_AUTOFIX_USERS.includes(context.actor)) { |
| 54 |
console.log('Cancelling'); |
| 55 |
const run_id = "${{ github.run_id }}"; |
| 56 |
await github.actions.cancelWorkflowRun({ owner, repo, run_id }); |
| 57 |
return 'go'; |
| 58 |
} else { |
| 59 |
return 'stay'; |
| 60 |
} |
| 61 |
- name: Wait for cancellation |
| 62 |
run: sleep 60 |
| 63 |
if: steps.check.outputs.result == 'go' |
| 64 |
- name: Should build? |
| 65 |
run: test "${{ steps.check.outputs.result }}" = "stay" |
| 66 |
# Setup to run sanity suite |
| 67 |
- name: Install Python Interpreter |
| 68 |
uses: actions/setup-python@v4 |
| 69 |
with: |
| 70 |
python-version: 3.8 |
| 71 |
- name: Install Python Packages |
| 72 |
run: | |
| 73 |
pip install pyyaml mako virtualenv |
| 74 |
sudo apt-get update |
| 75 |
sudo apt-get install python3-dev |
| 76 |
- name: Check out repository code |
| 77 |
uses: actions/checkout@v3 |
| 78 |
with: |
| 79 |
submodules: True |
| 80 |
- name: Get the upstream code |
| 81 |
run: | |
| 82 |
cd ${{ github.workspace }} |
| 83 |
git remote add upstream https://github.com/grpc/grpc |
| 84 |
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 upstream master |
| 85 |
# Run the things! |
| 86 |
- name: clang-tidy fixes |
| 87 |
run: ${{ github.workspace }}/tools/distrib/clang_tidy_code.sh --fix --only-changed || true |
| 88 |
- name: Run sanitize |
| 89 |
run: ${{ github.workspace }}/tools/distrib/sanitize.sh |
| 90 |
# Report back with a PR if things are broken |
| 91 |
- name: Create Pull Request |
| 92 |
uses: peter-evans/create-pull-request@v3 |
| 93 |
with: |
| 94 |
delete-branch: true |
| 95 |
branch-suffix: short-commit-hash |
| 96 |
commit-message: "Automated change: Fix sanity tests" |
| 97 |
title: Automated fix for ${{ github.ref }} |
| 98 |
body: | |
| 99 |
PanCakes to the rescue! |
| 100 |
|
| 101 |
We noticed that our 'sanity' test was going to fail, but we think we can fix that automatically, so we put together this PR to do just that! |
| 102 |
|
| 103 |
If you'd like to opt-out of these PR's, add yourself to NO_AUTOFIX_USERS in .github/workflows/pr-auto-fix.yaml |