"Require status check xyz expected" even after waiting for it to pass

Hi! In my repo (p00f/nvim-ts-rainbow because new users can only post 2 links), I have a two workflows: a linter and a formatter to format code if the linter says OK
The linter is

name: luacheck
on:
  push: {branches: ["master"]}
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  luacheck:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Install and run Luacheck
      run: |
        sudo apt-get install luarocks
        luarocks install --local luacheck
        /home/runner/.luarocks/bin/luacheck . -q --globals "vim" --allow-defined-top

The formatter is

name: stylua
on:
  push: {branches: ["master"]}

jobs:
  stylua:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0
    - name: Install and run stylua
      run: |
        wget "https://github.com/JohnnyMorganz/StyLua/releases/download/v0.6.0/stylua-0.6.0-linux.zip" -O /home/runner/stylua.zip
        unzip /home/runner/stylua.zip -d /home/runner
        chmod +x /home/runner/stylua
        /home/runner/stylua lua/* --config-path=stylua.toml
    - name: Commit files
      run: |
        git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
        git config --local user.name "github-actions[bot]"
        git commit -m "Format lua" lua/*
    - name: Wait for luacheck to succeed
      uses: fountainhead/action-wait-for-check@v1.0.0
      id: wait-for-luacheck
      with:
          token: ${{ secrets.GITHUB_TOKEN }}
          checkName: luacheck
          ref: ${{ github.sha }}
    - name: Push changes
      uses: ad-m/github-push-action@master
      if: steps.wait-for-luacheck.outputs.conclusion == 'success'
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        branch: ${{ github.ref }}

I use GitHub - fountainhead/action-wait-for-check: A GitHub Action that waits for another Check Run to have completed to wait for the linter to pass, and GitHub - ad-m/github-push-action: GitHub actions to push back to repository eg. updated code to push

The check (for the linter action) reports success

> Run fountainhead/action-wait-for-check@v1.0.0
Retrieving check runs named luacheck on p00f/nvim-ts-rainbow@87df1afc6e8dd75140d5c5d445f8bc15086cf734...
Retrieved 1 check runs named luacheck
Found a completed check with id xxxxxxxx and conclusion success

But pushing fails

>Run ad-m/github-push-action@master
Push to branch refs/heads/master
remote: error: GH006: Protected branch update failed for refs/heads/master.        
remote: error: Required status check "luacheck" is expected.        
To https://github.com/p00f/nvim-ts-rainbow.git
 ! [remote rejected] HEAD -> master (protected branch hook declined)
error: failed to push some refs to 'https://github.com/p00f/nvim-ts-rainbow.git'
Error: Invalid exit code: 1
    at ChildProcess.<anonymous> (/home/runner/work/_actions/ad-m/github-push-action/master/start.js:29:21)
    at ChildProcess.emit (events.js:210:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
  code: 1
}
Error: Invalid exit code: 1
    at ChildProcess.<anonymous> (/home/runner/work/_actions/ad-m/github-push-action/master/start.js:29:21)
    at ChildProcess.emit (events.js:210:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)

I assume you have a branch protection rule for the master branch? In that case the push of the new commit will be rejected because the check hasn’t run for that commit, only for the one that triggered the workflows.

As a side note, waiting for the linter to be done would be much easier to do with both jobs in one workflow, and a needs: luacheck in the stylua job.

the check hasn’t run for that commit, only for the one that triggered the workflows.

ahh right

As a side note, waiting for the linter to be done would be much easier to do with both jobs in one workflow, and a needs: luacheck in the stylua job.

Even if I do this, luacheck will only have run for the previous commit right?

If there’s no way out I’ll just remove the branch protection rule and wait for luacheck to pass

That’s correct, that’s how the branch protection rule is supposed to work. The workflow would just be easier to understand and use less run time.

To make this work with the branch protection rule you’d have to apply the formatting to a non-protected branch before merging.