Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit running gitlint in the CI #298

Merged
merged 5 commits into from
Apr 17, 2023

Conversation

phlogistonjohn
Copy link
Collaborator

After having to fight with actions/checkout in another repo for other reasons I learned a few things that may help us run the commit checks in the github ci

Unlike the other tools gitlint is python, but that's not much of a
stretch to install it like the other Go based tools.  The naming is now
a bit wrong, but that's a problem that can be fixed later.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
@phlogistonjohn
Copy link
Collaborator Author

@synarete what do you think? I think the big differences between this and #274 is that I added gitlint to be auto installed like many of the other tools and then the thing that "makes it work" in the CI is to use the ref argument to checkout action as well as using the origin/ prefix on the branch name.

@synarete
Copy link
Collaborator

synarete commented Apr 9, 2023

@synarete what do you think? I think the big differences between this and #274 is that I added gitlint to be auto installed like many of the other tools and then the thing that "makes it work" in the CI is to use the ref argument to checkout action as well as using the origin/ prefix on the branch name.

@phlogistonjohn Installing gitlint locally (like we do with other bin tools) looks great. That said, make check-gitlint still fails when integrated with github actions. See: https://github.com/synarete/samba-operator/actions/runs/4649123528/jobs/8227255345

@phlogistonjohn
Copy link
Collaborator Author

@synarete what do you think? I think the big differences between this and #274 is that I added gitlint to be auto installed like many of the other tools and then the thing that "makes it work" in the CI is to use the ref argument to checkout action as well as using the origin/ prefix on the branch name.

@phlogistonjohn Installing gitlint locally (like we do with other bin tools) looks great. That said, make check-gitlint still fails when integrated with github actions. See: https://github.com/synarete/samba-operator/actions/runs/4649123528/jobs/8227255345

It's possible I overlooked something but I don't think the version you are testing is setting the ref parameter for actions/checkout@v3. I copy and paste the text below from the run you linked:

Run actions/checkout@v3
  with:
    fetch-depth: 0
    repository: synarete/samba-operator
    token: ***
    ssh-strict: true
    persist-credentials: true
    clean: true
    lfs: false
    submodules: false
    set-safe-directory: true
Syncing repository: synarete/samba-operator

Try setting ref: ${{ github.event.pull_request.head.sha }} as a sibling to fetch-depth: 0, and see if that improves things for you. Notice how in my run it sets ref and it only logs an error for the "bad news" commit - as that is an intential failing commit I use to check the check and I plan to remove before merging

@phlogistonjohn
Copy link
Collaborator Author

On second thought, I think I understand now. You're basing this run off of my commits but you are not running them as part of a PR. So while I think you have the key specified in the job, the value ${{ github.event.pull_request.head.sha }} maps to nothing because you are running it on a "raw" branch not a PR. So there's no pull_request sub section! We probably don't need this check on anything not a PR anyway so we can add if: github.event_name == 'pull_request' to the job so that it only runs if pull_request is going to have data in it.

@synarete
Copy link
Collaborator

synarete commented Apr 9, 2023

@synarete what do you think? I think the big differences between this and #274 is that I added gitlint to be auto installed like many of the other tools and then the thing that "makes it work" in the CI is to use the ref argument to checkout action as well as using the origin/ prefix on the branch name.

@phlogistonjohn Installing gitlint locally (like we do with other bin tools) looks great. That said, make check-gitlint still fails when integrated with github actions. See: https://github.com/synarete/samba-operator/actions/runs/4649123528/jobs/8227255345

It's possible I overlooked something but I don't think the version you are testing is setting the ref parameter for actions/checkout@v3. I copy and paste the text below from the run you linked:

Run actions/checkout@v3
  with:
    fetch-depth: 0
    repository: synarete/samba-operator
    token: ***
    ssh-strict: true
    persist-credentials: true
    clean: true
    lfs: false
    submodules: false
    set-safe-directory: true
Syncing repository: synarete/samba-operator

Try setting ref: ${{ github.event.pull_request.head.sha }} as a sibling to fetch-depth: 0, and see if that improves things for you. Notice how in my run it sets ref and it only logs an error for the "bad news" commit - as that is an intential failing commit I use to check the check and I plan to remove before merging

@phlogistonjohn ref is properly set, see https://github.com/synarete/samba-operator/blob/ss-gitlint-review/.github/workflows/main.yml#L32-L42

Yor made a test with expected-to-fail commit, while I tried with should-not-fail commits. This is the same problem I encountered in my previous iteration with gitlint: when run via github actions make check-gitlint failed on valid commits (but does not happen on local repository).

@synarete
Copy link
Collaborator

synarete commented Apr 9, 2023

On second thought, I think I understand now. You're basing this run off of my commits but you are not running them as part of a PR. So while I think you have the key specified in the job, the value ${{ github.event.pull_request.head.sha }} maps to nothing because you are running it on a "raw" branch not a PR. So there's no pull_request sub section! We probably don't need this check on anything not a PR anyway so we can add if: github.event_name == 'pull_request' to the job so that it only runs if pull_request is going to have data in it.

@phlogistonjohn Good catch!

Copy link
Collaborator

@synarete synarete left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@anoopcs9
Copy link
Collaborator

anoopcs9 commented Apr 14, 2023

/retest centos-ci/sink-clustered/mini-k8s-1.26

@anoopcs9
Copy link
Collaborator

We probably don't need this check on anything not a PR anyway so we can add if: github.event_name == 'pull_request' to the job so that it only runs if pull_request is going to have data in it.

What happened to this part? Don't we need to differentiate pull_request and other events?

@phlogistonjohn
Copy link
Collaborator Author

We probably don't need this check on anything not a PR anyway so we can add if: github.event_name == 'pull_request' to the job so that it only runs if pull_request is going to have data in it.

What happened to this part? Don't we need to differentiate pull_request and other events?

Hah. I apparently added it to the sambacc version instead of this PR:
samba-in-kubernetes/sambacc@dda4f72#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR15

Will fix.

Copy link
Collaborator

@obnoxxx obnoxxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good in general but found one typo ...

hack/install-tools.sh Show resolved Hide resolved
@phlogistonjohn
Copy link
Collaborator Author

/retest centos-ci/sink-clustered/mini-k8s-1.26

Copy link
Collaborator

@obnoxxx obnoxxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typofix mentioned previously

@obnoxxx obnoxxx dismissed their stale review April 14, 2023 17:21

it has been addressed

@phlogistonjohn
Copy link
Collaborator Author

Storing signatures
kustomize not found in PATH, checking /root/samba-operator/.bin
make: *** [Makefile:256: kustomize] Error 1
Build step 'Execute shell' marked build as failure
Performing Post build task...

I don't see how my change would have broken the install for kustomize... but I did touch the file that makes it happen.
I tried running it locally and it succeeded.

obnoxxx
obnoxxx previously approved these changes Apr 14, 2023
Copy link
Collaborator

@obnoxxx obnoxxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after more careful review, the PR lgtm, but a ci check is failing. this needs to be fixed to meet all requirements

@obnoxxx obnoxxx mentioned this pull request Apr 14, 2023
@anoopcs9
Copy link
Collaborator

Storing signatures
kustomize not found in PATH, checking /root/samba-operator/.bin
make: *** [Makefile:256: kustomize] Error 1
Build step 'Execute shell' marked build as failure
Performing Post build task...

I don't see how my change would have broken the install for kustomize... but I did touch the file that makes it happen. I tried running it locally and it succeeded.

Even my local run completed successfully with the patch. I'll take a look at it later.

anoopcs9
anoopcs9 previously approved these changes Apr 14, 2023
If a dependency of the script (go, python) is missing the script would
silently fail very early on. This change tries to avoid any failure
unless the tool in question actually depends on that dependency while
also making the missing dependency more obvious with more output.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Don't assume local branches exist, but do assume branches in origin.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Install gitlint into the "GOBIN_ALT" dir if gitlint is not present.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Based-On: 07e30e2
Credit-To: Shachar Sharon <ssharon@redhat.com>
Signed-off-by: John Mulligan <jmulligan@redhat.com>
@phlogistonjohn
Copy link
Collaborator Author

I fixed the CI failure. install-tools.sh broke silently when either go (not in this case) or python3 (which failed in this case) were not on the system it also didn't matter if that was being used or not, so I updated the script with a 2nd patch.

Copy link
Collaborator

@anoopcs9 anoopcs9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

@anoopcs9
Copy link
Collaborator

I fixed the CI failure. install-tools.sh broke silently when either go (not in this case) or python3 (which failed in this case) were not on the system it also didn't matter if that was being used or not, so I updated the script with a 2nd patch.

Awesome find 👏🏻

Especially I liked the part where you added another commit instead of squashing the dependency change into previous one which kind of helped me easily understand the "missing python3" error in CentOS CI.

Copy link
Collaborator

@obnoxxx obnoxxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mergify mergify bot merged commit eea7035 into samba-in-kubernetes:master Apr 17, 2023
12 checks passed
@phlogistonjohn phlogistonjohn deleted the jjm-gitlint branch April 17, 2023 14:42
@mergify mergify bot added the priority-review This PR deserves a look label May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-review This PR deserves a look
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants