siderolabs / conform

Policy enforcement for your pipelines.
Mozilla Public License 2.0
432 stars 45 forks source link

Conform Action fails on PR with: failed to get commit message: object not found #231

Open janderssonse opened 2 years ago

janderssonse commented 2 years ago

When running a dco check on a PR, conform enforce fails with "failed to get commit message: object not found".

How to trigger:

1) Create a sample project on github. In that, include a .conform,yaml ensuring dco: true is set under policies etc.

policies:
  - type: commit
    spec:
      dco: true 

2) Using the sidero confirm GitHub action, do a commit to main branch (with dco), see the pipeline succeeds and confirm gives success, A simple GitHub action example

  name: Conform DCO (--Sign-off)
  on: ...add on PR etc 

  jobs:
   signoff:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v3
       - name: Conform Action
         uses: siderolabs/conform@v0.1.0-alpha.26

3) Now, do a git checkout -b feat/my-feat, commit a valid commit. If running local conform enforce, it will succed. Then push to a new branch git push -u origin feat/my-feat etc., and make sure conform was run (on push or whatever you did set it to trigger on). Fails. Merge to main and conform will succed again (on the main branch).

So, it fails on PR to main with: failed to get commit message: object not found

Mallear commented 1 year ago

Hello @janderssonse I have setup this action today and ran into this issue. I think this is due to the v3 of the checkout action which does fetched only one commit (see their Readme).

I've managed to get Conform action working by setting this:

      - uses: actions/checkout@v3
        with:
          fetch-depth: 2
      - name: Conform action
        uses: siderolabs/conform@v0.1.0-alpha.27
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

Hope it helps.

janderssonse commented 1 year ago

It did, thanks!