-
Notifications
You must be signed in to change notification settings - Fork 617
Add MegaLinter #679
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
Add MegaLinter #679
Changes from all commits
496663a
90de4bd
0563476
beb5720
5b89f26
40bfe06
a37abee
9c04270
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [flake8] | ||
| max-line-length = 120 | ||
| extend-ignore = E203 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| --- | ||
| # MegaLinter GitHub Action configuration file | ||
| # More info at https://megalinter.github.io | ||
| name: MegaLinter | ||
|
|
||
| 'on': [pull_request_target] | ||
|
|
||
| env: # Comment env block if you do not want to apply fixes | ||
| # Apply linter fixes configuration | ||
| APPLY_FIXES: all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool) | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
|
|
||
| concurrency: | ||
| group: ${{ github.ref }}-${{ github.workflow }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build: | ||
| name: MegaLinter | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| # Git Checkout | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| # MegaLinter | ||
| - name: MegaLinter | ||
| id: ml | ||
| # You can override MegaLinter flavor used to have faster performances | ||
| # More info at https://megalinter.github.io/flavors/ | ||
| uses: megalinter/megalinter@v5 | ||
| env: | ||
| # All available variables are described in documentation | ||
| # https://megalinter.github.io/configuration/ | ||
| VALIDATE_ALL_CODEBASE: false # ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} # Validates all source when push on master, else just the git diff with master. Override with true if you always want to lint all sources | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| # ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY | ||
| # DISABLE: COPYPASTE,SPELL # Uncomment to disable copy-paste and spell checks | ||
|
|
||
| # Create or delete the cleanup branch | ||
| - name: Update cleanup branch | ||
| if: ${{ github.event.repository.owner.login == 'AliceO2Group' }} | ||
| env: | ||
| REMOTE_URL: "https://alibuild:${{ secrets.ALIBUILD_GITHUB_TOKEN }}@\ | ||
| github.com/alibuild/${{ github.event.repository.name }}" | ||
| run: | | ||
| # An empty CLEANUP_COMMIT means delete the branch. | ||
| CLEANUP_COMMIT="" | ||
| if [ "${{ steps.ml.outputs.has_updated_sources }}" = 1 ] | ||
| then | ||
| CLEANUP_COMMIT="HEAD" | ||
| git commit -am "MegaLinter fixes" | ||
| fi | ||
| git push -f "$REMOTE_URL" "$CLEANUP_COMMIT:refs/heads/alibot-cleanup-ml-$PR_NUMBER" | ||
|
|
||
| - name: Create pull request with applied fixes | ||
| uses: alisw/pull-request@v2 | ||
| if: steps.ml.outputs.has_updated_sources == 1 && ${{ github.event.repository.owner.login == 'AliceO2Group' }} | ||
| with: | ||
| source_branch: 'alibuild:alibot-cleanup-ml-${{ env.PR_NUMBER }}' | ||
| destination_branch: '${{ github.event.pull_request.head.label }}' | ||
| github_token: ${{ secrets.ALIBUILD_GITHUB_TOKEN }} | ||
| pr_title: >- | ||
| [MegaLinter] Apply linters automatic fixes to | ||
| #${{ env.PR_NUMBER }} | ||
| pr_body: >- | ||
| Your PR ${{ github.event.repository.full_name }}#${{ env.PR_NUMBER }} | ||
| cannot be merged as is. You should either run MegaLinter | ||
| yourself and update the pull request, or merge this PR in yours. | ||
|
|
||
| You can find how to run MegaLinter locally at | ||
| <https://megalinter.github.io/latest/mega-linter-runner/>. | ||
| continue-on-error: true # We do not create PRs if the branch is not there. | ||
|
|
||
| - name: Exit with error if the PR is not clean | ||
| run: | | ||
| case "${{ steps.ml.outputs.has_updated_sources }}" in | ||
| 0) echo 'PR clean' ; exit 0 ;; | ||
| 1) echo 'PR not clean' ; exit 1 ;; | ||
| esac | ||
|
Comment on lines
+77
to
+82
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is the case handled where MegaLinter finds problems, but does not have automatic fixes for them? In that case, we still want to exit with an error, right?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, in case of errors, the MegaLinter step fails.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case, the automatic PR with any fixes that MegaLinter does produce wouldn't be created, right?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is correct. The formatting PR should be created only if MegaLinter did not find any errors, which I think is the intended behaviour, right? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,17 @@ | ||
| --- | ||
| name: "Close stale PRs" | ||
| on: | ||
| schedule: | ||
| - cron: "0 0 * * *" | ||
| - cron: "0 0 * * *" | ||
|
|
||
| jobs: | ||
| stale: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/stale@v1 | ||
| with: | ||
| repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
| stale-pr-message: 'This PR has not been updated in the last 30 days. Is it still needed? Unless further action is taken, it will be closed in 5 days.' | ||
| stale-pr-label: stale | ||
| days-before-stale: 30 | ||
| days-before-close: 5 | ||
| - uses: actions/stale@v1 | ||
| with: | ||
| repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
| stale-pr-message: 'This PR has not been updated in the last 30 days. Is it still needed? Unless further action is taken, it will be closed in 5 days.' | ||
| stale-pr-label: stale | ||
| days-before-stale: 30 | ||
| days-before-close: 5 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --- | ||
| # Configuration file for Mega-Linter | ||
| # See all available variables at https://megalinter.github.io/configuration/ and in linters documentation | ||
|
|
||
| APPLY_FIXES: all # all, none, or list of linter keys | ||
| DEFAULT_BRANCH: master # Usually master or main | ||
| # ENABLE: # If you use ENABLE variable, all other languages/formats/tooling-formats will be disabled by default | ||
| # ENABLE_LINTERS: # If you use ENABLE_LINTERS variable, all other linters will be disabled by default | ||
| DISABLE: | ||
| - C | ||
| - COPYPASTE # abusive copy-pastes | ||
| - SPELL # spelling mistakes | ||
| DISABLE_LINTERS: | ||
| - CPP_CPPLINT | ||
| - BASH_EXEC | ||
| - BASH_SHFMT | ||
| - JSON_PRETTIER | ||
| - YAML_V8R | ||
| - YAML_PRETTIER | ||
| SHOW_ELAPSED_TIME: true | ||
| FILEIO_REPORTER: false | ||
| GITHUB_COMMENT_REPORTER: false | ||
| UPDATED_SOURCES_REPORTER: false | ||
| PRINT_ALPACA: false # Don't print ASCII alpaca in the log |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| # O2Physics | ||
|
|
||
| Documentation for the ALICE Analysis framework is available at: | ||
|
|
||
| https://aliceo2group.github.io/analysis-framework/ | ||
| <https://aliceo2group.github.io/analysis-framework/> |
Uh oh!
There was an error while loading. Please reload this page.