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

Github CI does not run upon Github, rebase action #11134

Closed
nrmancuso opened this issue Dec 30, 2021 · 12 comments · Fixed by #12951
Closed

Github CI does not run upon Github, rebase action #11134

nrmancuso opened this issue Dec 30, 2021 · 12 comments · Fixed by #12951

Comments

@nrmancuso
Copy link
Member

nrmancuso commented Dec 30, 2021

After PRs are rebased with Github, rebase, all other CI runs except for Github CI.

Example from #10999:
image

Another example, from #11112:

image

Click to see tasks that ran in each PR
@cirrus-ci
Cirrus - JDK17 Successful in 20m — Task Summary
Details
@romani
IDEA Inspections Pull Request (Checkstyle) — TeamCity build finished
Details
@travis-ci
Travis CI - Pull Request Successful in 17m — Build Passed
Details
@azure-pipelines
checkstyle.checkstyle Successful in 13m — Build #20211228.10 succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job MacOS JDK11 verify) Successful in 13m — Job MacOS JDK11 verify succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job MacOS JDK13 verify) Successful in 11m — Job MacOS JDK13 verify succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job MacOS JDK14 verify) Successful in 10m — Job MacOS JDK14 verify succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job MacOS JDK8 verify) Successful in 9m — Job MacOS JDK8 verify succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job OpenJDK11 verify) Successful in 6m — Job OpenJDK11 verify succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job markdownlint) Successful in 19s — Job markdownlint succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job pr-age) Successful in 12s — Job pr-age succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job spelling) Successful in 23s — Job spelling succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test) Successful in 2m — Job test succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-de) Successful in 3m — Job test-de succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-es) Successful in 3m — Job test-es succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-fi) Successful in 2m — Job test-fi succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-fr) Successful in 3m — Job test-fr succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-ja) Successful in 2m — Job test-ja succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-pt) Successful in 3m — Job test-pt succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-tr) Successful in 3m — Job test-tr succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-zh) Successful in 2m — Job test-zh succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job versions) Successful in 22s — Job versions succeeded
Details

ci/circleci: no-error-xwiki — Your tests passed on CircleCI!
Details

ci/circleci: no-exception-cassandra-storm-tapestry-javadoc — Your tests passed on CircleCI!
Details

ci/circleci: no-exception-hadoop-apache-groovy-scouter-javadoc — Your tests passed on CircleCI!
Details

ci/circleci: no-exception-lucene-and-others-javadoc — Your tests passed on CircleCI!
Details

ci/circleci: no-exception-only-javadoc — Your tests passed on CircleCI!
Details

ci/semaphoreci/pr: Checkstyle CI pipeline on Semaphore — The build passed on Semaphore 2.0.
Details

continuous-integration/appveyor/pr — AppVeyor build succeeded
Details

continuous-integration/drone/pr — Build is passing
Details

security/snyk (checkstyle) — No manifest changes detected in 1 project
Details

wercker/build — Wercker pipeline passed

In each, a total of 32 checks ran.


Expected behavior of CI:

Example:
image

Note there is a total of 62 checks normally.

Click to see tasks that ran in PR with no rebase action
@github-actions
Check PR Description / Analyze (pull_request) Successful in 6s
Details
@github-actions
CodeQL / Analyze (java) (pull_request) Successful in 4m
Details
@github-actions
Pitest / pitest-annotation (pull_request) Successful in 2m
Details
@github-actions
no-exception testing / no-exception-openjdk16 (pull_request) Successful in 62m
Details
@github-actions
Pitest / pitest-ant (pull_request) Successful in 1m
Details
@github-actions
Pitest / pitest-api (pull_request) Successful in 3m
Details
@github-actions
Pitest / pitest-blocks (pull_request) Successful in 1m
Details
@github-actions
Pitest / pitest-coding (pull_request) Successful in 7m
Details
@github-actions
Pitest / pitest-common (pull_request) Successful in 3m
Details
@github-actions
Pitest / pitest-common-2 (pull_request) Successful in 3m
Details
@github-actions
Pitest / pitest-design (pull_request) Successful in 2m
Details
@github-actions
Pitest / pitest-filters (pull_request) Successful in 2m
Details
@github-actions
Pitest / pitest-header (pull_request) Successful in 1m
Details
@github-actions
Pitest / pitest-imports (pull_request) Successful in 2m
Details
@github-actions
Pitest / pitest-indentation (pull_request) Successful in 8m
Details
@github-actions
Pitest / pitest-javadoc (pull_request) Successful in 8m
Details
@github-actions
Pitest / pitest-main (pull_request) Successful in 2m
Details
@github-actions
Pitest / pitest-metrics (pull_request) Successful in 2m
Details
@github-actions
Pitest / pitest-misc (pull_request) Successful in 4m
Details
@github-actions
Pitest / pitest-modifier (pull_request) Successful in 1m
Details
@github-actions
Pitest / pitest-naming (pull_request) Successful in 2m
Details
@github-actions
Pitest / pitest-packagenamesloader (pull_request) Successful in 1m
Details
@github-actions
Pitest / pitest-regexp (pull_request) Successful in 2m
Details
@github-actions
Pitest / pitest-sizes (pull_request) Successful in 1m
Details
@github-actions
Pitest / pitest-tree-walker (pull_request) Successful in 2m
Details
@github-actions
Pitest / pitest-utils (pull_request) Successful in 4m
Details
@github-actions
Pitest / pitest-whitespace (pull_request) Successful in 3m
Details
@github-actions
Pitest / pitest-xpath (pull_request) Successful in 1m
Details
@github-actions
Pitest / pitest-java-ast-visitor (pull_request) Successful in 4m
Details
@cirrus-ci
Cirrus - JDK17 Successful in 22m — Task Summary
Details
@github-code-scanning
Code scanning results / CodeQL Successful in 2s — No new or fixed alerts
Details
@romani
IDEA Inspections Pull Request (Checkstyle) — TeamCity build finished
Details
@travis-ci
Travis CI - Pull Request Successful in 27m — Build Passed
Details
@azure-pipelines
checkstyle.checkstyle Successful in 10m — Build #20211222.17 succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job MacOS JDK11 verify) Successful in 8m — Job MacOS JDK11 verify succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job MacOS JDK13 verify) Successful in 7m — Job MacOS JDK13 verify succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job MacOS JDK14 verify) Successful in 9m — Job MacOS JDK14 verify succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job MacOS JDK8 verify) Successful in 6m — Job MacOS JDK8 verify succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job OpenJDK11 verify) Successful in 5m — Job OpenJDK11 verify succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job markdownlint) Successful in 21s — Job markdownlint succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job pr-age) Successful in 11s — Job pr-age succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job spelling) Successful in 26s — Job spelling succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test) Successful in 2m — Job test succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-de) Successful in 3m — Job test-de succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-es) Successful in 3m — Job test-es succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-fi) Successful in 3m — Job test-fi succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-fr) Successful in 3m — Job test-fr succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-ja) Successful in 3m — Job test-ja succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-pt) Successful in 3m — Job test-pt succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-tr) Successful in 3m — Job test-tr succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job test-zh) Successful in 3m — Job test-zh succeeded
Details
@azure-pipelines
checkstyle.checkstyle (Job versions) Successful in 21s — Job versions succeeded
Details

ci/circleci: no-error-xwiki — Your tests passed on CircleCI!
Details

ci/circleci: no-exception-cassandra-storm-tapestry-javadoc — Your tests passed on CircleCI!
Details

ci/circleci: no-exception-hadoop-apache-groovy-scouter-javadoc — Your tests passed on CircleCI!
Details

ci/circleci: no-exception-lucene-and-others-javadoc — Your tests passed on CircleCI!
Details

ci/circleci: no-exception-only-javadoc — Your tests passed on CircleCI!
Details

ci/semaphoreci/pr: Checkstyle CI pipeline on Semaphore — The build passed on Semaphore 2.0.
Details

continuous-integration/appveyor/pr — AppVeyor build succeeded
Details

continuous-integration/drone/pr — Build is passing
Details

security/snyk (checkstyle) — No manifest changes detected in 1 project
Details

wercker/build — Wercker pipeline passed
Details

@nrmancuso nrmancuso added the CI label Dec 30, 2021
@Vyom-Yadav
Copy link
Member

on it.

@Vyom-Yadav
Copy link
Member

Vyom-Yadav commented Jan 3, 2022

@nmancus1 @romani @strkkk The reason rebase is not triggering new workflows is due to the fact that it uses default GITHUB_TOKEN and any PR's made by this default token won't trigger any workflows (GitHub actions based).

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Related documentation-
https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token
The workaround github suggests uses PAT but PAT stays forever so I found a workaround that involves-

Authenticating with GitHub App generated tokens

A GitHub App can be created for the sole purpose of generating tokens for use with GitHub actions.
These tokens can be used in place of GITHUB_TOKEN or a Personal Access Token (PAT).
GitHub App generated tokens are more secure than using a PAT because GitHub App access permissions can be set with finer granularity and are scoped to only repositories where the App is installed.

  1. Create a minimal GitHub App, setting the following fields:
    - Set GitHub App name.
    - Set Homepage URL to anything you like, such as your GitHub profile page.
    - Uncheck Active under Webhook. You do not need to enter a Webhook URL.
    - Under Repository permissions: Contents select Access: Read & write.
    - Under Repository permissions: Pull requests select Access: Read & write.
  2. Create a Private key from the App settings page and store it securely.
  3. Install the App on any repository where workflows will run requiring tokens.
  4. Set secrets on your repository containing the GitHub App ID, and the private key you created in step 2. e.g. APP_ID, APP_PRIVATE_KEY.
  5. The following example workflow shows how to use tibdex/github-app-token to generate a token for use with this action.
    steps:
      - uses: actions/checkout@v2

      - uses: tibdex/github-app-token@v1
        id: generate-token
        with:
          app_id: ${{ secrets.APP_ID }}
          private_key: ${{ secrets.APP_PRIVATE_KEY }}

      # Make changes to pull request here

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v3
        with:
          token: ${{ steps.generate-token.outputs.token }}

source
I even tested this out in a test repo I made, https://github.com/Vyom-Yadav/actions-test.
Here is when I triggered rebase and the CI build was started again - Vyom-Yadav/actions-test#3
Vyom-Yadav/actions-test#2

Edit- There will be a difference, action won't be completed by the Github action bot but by the GitHub app you made for the repo, and that GitHub app will run on behalf of the user who created it, in the PR above mentioned you can see it ran on my behalf.

@nrmancuso
Copy link
Member Author

@Vyom-Yadav thanks for investigating and making detailed example. Is it possible to use Github workflow API to run other workflows (Github CI tasks) from rebase.yml if rebase action is successful instead of PAT or specially created github app?

@Vyom-Yadav
Copy link
Member

@nmancus1 Intrigued by your suggestion to use workflow API to run workflows I gave it a shot in my https://github.com/Vyom-Yadav/actions-test repo. I was expecting it to fail with the GITHUB_TOKEN, as automatic triggers do not support that (so manual also shouldn't support). The results-

  • Was able to manually trigger a workflow using PAT but not using GITHUB_TOKEN, some commands if you want to also give it a try-
- name: Manually trigger another workflow
        run: |
          curl \
          -X POST \
          -H "Authorization: token $token" \
          -H "Accept: application/vnd.github.v3+json" \
          https://api.github.com/repos/Vyom-Yadav/actions-test/actions/workflows/action1.yml/dispatches \
          -d '{"ref":"testingRestApi"}'
        env:
          token: ${{ secrets.GITHUB_TOKEN }}

won't work with GITHUB_TOKEN, replace it with-

env:
   token: ${{ secrets.PAT }}

for the workflow to be triggered.

  • The manually triggered workflow won't appear in the checks column of the PR, it would be only visible in the actions tab.
    image
    It won't appear here ↑

Github currently doesn't support manually triggered workflows to appear in checks tab. You will find a difference between GITHUB_REF on manual workflow and automatic workflow, for me in manual it was refs/heads/testingRestApi, and in automatic it was refs/pull/4/merge. You cannot pass in refs/pull/4/merge as the ref parameter in the body of API call, documentation says-

ref - Required. The git reference for the workflow. The reference can be a branch or tag name.

So now only solution in my opinion is to use PAT or a Github App. If you do not want to use either of them just close and reopen the PR after rebase, the checks will run again, which is not recommended.
If you are concerned about security of Github App for generating tokens, it is better than PAT, the generated token remains usable for 60 sec or so which is better than PAT which may not even expire.

@rnveach
Copy link
Member

rnveach commented Oct 26, 2022

@nrmancuso @Vyom-Yadav Do we have a way forward to make this work again?

https://github.com/checkstyle/checkstyle/actions/runs/3325206341/jobs/5497637360

fatal: detected dubious ownership in repository at '/github/workspace'
To add an exception for this directory, call:
git config --global --add safe.directory /github/workspace

@romani
Copy link
Member

romani commented Oct 26, 2022

From CI
https://cloud.drone.io/checkstyle/checkstyle/13134/4/2

Cloning into 'checkstyle'...
LATEST_RELEASE_TAG=checkstyle-10.3.4
CS_RELEASE_VERSION=10.3.5
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

[WARN] Issue #12243 "Pitest/Checker: Drop New/Unnecessary Displays And Switch to Git Diff" is not closed! Please review issue https://github.com/checkstyle/checkstyle/issues/12243
[WARN] Issue #11214 "Specify violation messages in input files." is not closed! Please review issue https://github.com/checkstyle/checkstyle/issues/11214

Generation ends with 1 errors.

There are no error message that we expect.

@romani
Copy link
Member

romani commented Mar 7, 2023

We already use PAT a lot. Let's use to let benefit from this action.

@stoyanK7 , can we reuse your master experience in actions to make our rebase work again?

@stoyanK7
Copy link
Contributor

@romani

Can you first check this out? It came out in Feb 2022. https://github.blog/changelog/2022-02-03-more-ways-to-keep-your-pull-request-branch-up-to-date/

Reading the documentation on it, I understand that

people with write permissions will always have the ability, on the pull request page, to update a pull request's head branch when it's not up to date with the base branch.


If the above proposal is not what you are looking for, the only thing that needs to be done is to switch from GITHUB_TOKEN to PAT. Maybe also add persist-credentials: false(see actions/checkout#485 (comment))

From what I've seen before, I suppose PAT has quite a lot of permissions. For security reasons, you can create a new personal access token REBASE_TOKEN(for example) with only these permissions:

permissions:
contents: write
pull-requests: write

@romani
Copy link
Member

romani commented Mar 16, 2023

@nrmancuso , what is your opinion on this ?

@nrmancuso
Copy link
Member Author

nrmancuso commented Mar 16, 2023

people with write permissions will always have the ability, on the pull request page, to update a pull request's head branch when it's not up to date with the base branch.

It is rare that we use origin branch for PRs, so this isn’t really an option.

I think we should create some service user, and create PAT from there with exact permissions.

However, we still assume some risk on the checkstyle side if someone was able to get the PAT. I could think of a few ways to do this, but I won’t enumerate them here. The question becomes: is this GitHub action worth having a token with write access compromised?

@romani
Copy link
Member

romani commented Apr 2, 2023

Based on https://github.blog/changelog/2022-02-03-more-ways-to-keep-your-pull-request-branch-up-to-date/

I activated at https://github.com/checkstyle/checkstyle/settings

Always suggest updating pull request branches
Whenever there are new changes available in the base branch, present an “update branch” option in the pull request.

And it works
#12665

@stoyanK7 , thanks a lot !!!
Please remove rebase action from our repo, as a fix for this issue.

romani pushed a commit that referenced this issue Apr 4, 2023
@github-actions github-actions bot added this to the 10.9.4 milestone Apr 4, 2023
@romani
Copy link
Member

romani commented Apr 4, 2023

Action is removed

Sloent pushed a commit to Sloent/checkstyle that referenced this issue Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants