1name: PR AutoFix 2on: [push] 3permissions: {} 4jobs: 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@5a4163ad035ccd9a407ec9e519c3b6ba1b633d1e # v1.1.0 16 id: current-time 17 with: 18 format: YYYYWW 19 - name: Get current time 20 uses: srfrnk/current-time@5a4163ad035ccd9a407ec9e519c3b6ba1b633d1e # v1.1.0 21 id: current-time-with-day 22 with: 23 format: YYYYWWd 24 - name: Cache bazel 25 uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 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/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1 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@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 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 = ["copybara-service[bot]"] 52 const { owner, repo } = context.repo 53 console.log("Actor: " + context.actor); 54 if (NO_AUTOFIX_USERS.includes(context.actor)) { 55 console.log('Cancelling'); 56 const run_id = "${{ github.run_id }}"; 57 await github.actions.cancelWorkflowRun({ owner, repo, run_id }); 58 return 'go'; 59 } else { 60 return 'stay'; 61 } 62 - name: Wait for cancellation 63 run: sleep 60 64 if: steps.check.outputs.result == 'go' 65 - name: Should build? 66 run: test "${{ steps.check.outputs.result }}" = "stay" 67 # Setup to run sanity suite 68 - name: Install Python Interpreter 69 uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 70 with: 71 python-version: 3.8 72 - name: Install Python Packages 73 run: | 74 pip install pyyaml mako virtualenv 75 sudo apt-get update 76 sudo apt-get install python3-dev 77 - name: Check out repository code 78 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 79 with: 80 submodules: True 81 - name: Get the upstream code 82 run: | 83 cd ${{ github.workspace }} 84 git remote add upstream https://github.com/grpc/grpc 85 git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 upstream master 86 # Run the things! 87 - name: clang-tidy fixes 88 run: ANDROID_NDK_HOME= ${{ github.workspace }}/tools/distrib/clang_tidy_code.sh --fix --only-changed || true 89 - name: Run sanitize 90 run: ANDROID_NDK_HOME= ${{ github.workspace }}/tools/distrib/sanitize.sh 91 # Report back with a PR if things are broken 92 - name: Create Pull Request 93 uses: peter-evans/create-pull-request@b1ddad2c994a25fbc81a28b3ec0e368bb2021c50 # v6.0.0 94 with: 95 delete-branch: true 96 branch-suffix: short-commit-hash 97 commit-message: "Automated change: Fix sanity tests" 98 title: Automated fix for ${{ github.ref }} 99 body: | 100 PanCakes to the rescue! 101 102 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! 103 104 If you'd like to opt-out of these PR's, add yourself to NO_AUTOFIX_USERS in .github/workflows/pr-auto-fix.yaml 105