-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
Apply pr2957 to mega-linter-runner/.../mega-linter.yml #3033
Changes from all commits
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 |
---|---|---|
|
@@ -125,7 +125,9 @@ jobs: | |
( | ||
github.event_name == 'push' || | ||
github.event.pull_request.head.repo.full_name == github.repository | ||
) | ||
) && | ||
!contains(github.event.head_commit.message, 'skip fix') | ||
|
||
Comment on lines
+128
to
+130
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. |
||
}}" >> "${GITHUB_ENV}" | ||
|
||
# Set APPLY_FIXES_IF_* vars for use in future steps | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,7 +120,8 @@ jobs: | |
( | ||
github.event_name == 'push' || | ||
github.event.pull_request.head.repo.full_name == github.repository | ||
) | ||
) && | ||
!contains(github.event.head_commit.message, 'skip fix') | ||
Comment on lines
+123
to
+124
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. 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. 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. I would prefer the 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.
Seems weird like that. We have one that is our own for dogfooding (the python@beta), another one for the second project (the node mega-linter-runner) again for dogfooding, then there is the one that is for the template for users, and all the duplicatas built into the documentation... I expect that these update from their sources when running |
||
}}" >> "${GITHUB_ENV}" | ||
|
||
# Set APPLY_FIXES_IF_* vars for use in future steps | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
--- | ||
name: MegaLinter | ||
|
||
# Trigger mega-linter at every push. Action will also be visible from | ||
# Pull Requests to main | ||
# Trigger mega-linter at every push. Action will also be visible from Pull | ||
# Requests to main | ||
Comment on lines
+6
to
+7
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. |
||
on: | ||
# Comment this line to trigger action only on pull-requests | ||
# (not recommended if you don't pay for GH Actions) | ||
|
@@ -41,16 +41,17 @@ jobs: | |
runs-on: ubuntu-latest | ||
|
||
# Give the default GITHUB_TOKEN write permission to commit and push, comment | ||
# issues, and post new Pull Requests; remove the ones you do not need | ||
# issues & post new PR; remove the ones you do not need | ||
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. |
||
permissions: | ||
contents: write | ||
issues: write | ||
pull-requests: write | ||
|
||
steps: | ||
|
||
# Git Checkout | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
Comment on lines
+51
to
+54
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. 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. @echoix one thing to consider with an upgrade to It's something we need to earmark for a test (and I have with the change I proposed) prior to merging this into MegaLinter's next release. 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. I think that the most important use case isn't with act, and thus, it way more important to not use a node version that is EOL since Sept 11, 2023 (node 16 used in actions/checkout@v3). Running locally with act, even if I have done it a couple of times in the past (when doing big changes in the docker building actions and multiplatform builds, iterating on GitHub was way too long), remains more of a hack than a supported (by us) use-case. Having an up to date runner image for act seems like the way to solve your interrogation. I don't understand the meaning of your last sentence, especially "earmark for a test", and what do you expect before a next release (that should be due soon IMO, maybe wait a little after we settled and merged the big template changes and other link changes PRs). 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. We should have pretty up-to-date nodejs on images. 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.
I wasn't able to run checkout@v4 on the latest images as Node 20 wasn't available, IIRC. |
||
with: | ||
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} | ||
|
||
|
@@ -62,14 +63,15 @@ jobs: | |
- name: MegaLinter | ||
|
||
# You can override MegaLinter flavor used to have faster performances | ||
# More info at https://megalinter.io/latest/flavors/ | ||
# More info at https://megalinter.io/flavors/ | ||
echoix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uses: <%= GITHUB_ACTION_NAME %>@<%= GITHUB_ACTION_VERSION %> | ||
|
||
id: ml | ||
|
||
# All available variables are described in documentation | ||
# https://megalinter.io/latest/config-file/ | ||
# https://megalinter.io/configuration/ | ||
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. The original would be the correct link, #2986 |
||
env: | ||
|
||
# Validates all source when push on main, else just the git diff with | ||
# main. Override with true if you always want to lint all sources | ||
# | ||
|
@@ -80,15 +82,18 @@ jobs: | |
# VALIDATE_ALL_CODEBASE: >- | ||
# ${{ | ||
# github.event_name == 'push' && | ||
# github.ref == 'refs/heads/main' | ||
# contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref) | ||
# }} | ||
VALIDATE_ALL_CODEBASE: <%- VALIDATE_ALL_CODE_BASE_GHA %> | ||
|
||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF | ||
# ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE | ||
# .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY | ||
|
||
# Uncomment to disable copy-paste and spell checks | ||
# DISABLE: COPYPASTE,SPELL | ||
|
||
# Upload MegaLinter artifacts | ||
- name: Archive production artifacts | ||
uses: actions/upload-artifact@v3 | ||
|
@@ -99,79 +104,62 @@ jobs: | |
megalinter-reports | ||
mega-linter.log | ||
|
||
# Set APPLY_FIXES_IF var for use in future steps | ||
- name: Set APPLY_FIXES_IF var | ||
run: | | ||
printf 'APPLY_FIXES_IF=%s\n' "${{ | ||
steps.ml.outputs.has_updated_sources == 1 && | ||
( | ||
env.APPLY_FIXES_EVENT == 'all' || | ||
env.APPLY_FIXES_EVENT == github.event_name | ||
) && | ||
( | ||
github.event_name == 'push' || | ||
github.event.pull_request.head.repo.full_name == github.repository | ||
) && | ||
!contains(github.event.head_commit.message, 'skip fix') | ||
}}" >> "${GITHUB_ENV}" | ||
|
||
# Set APPLY_FIXES_IF_* vars for use in future steps | ||
- name: Set APPLY_FIXES_IF_* vars | ||
run: | | ||
printf 'APPLY_FIXES_IF_PR=%s\n' "${{ | ||
env.APPLY_FIXES_IF == 'true' && | ||
env.APPLY_FIXES_MODE == 'pull_request' | ||
}}" >> "${GITHUB_ENV}" | ||
printf 'APPLY_FIXES_IF_COMMIT=%s\n' "${{ | ||
env.APPLY_FIXES_IF == 'true' && | ||
env.APPLY_FIXES_MODE == 'commit' && | ||
(!contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref)) | ||
}}" >> "${GITHUB_ENV}" | ||
|
||
# Create pull request if applicable | ||
# (for now works only on PR from same repository, not from forks) | ||
- name: Create Pull Request with applied fixes | ||
uses: peter-evans/create-pull-request@v5 | ||
id: cpr | ||
if: >- | ||
steps.ml.outputs.has_updated_sources == 1 && | ||
( | ||
env.APPLY_FIXES_EVENT == 'all' || | ||
env.APPLY_FIXES_EVENT == github.event_name | ||
) && | ||
env.APPLY_FIXES_MODE == 'pull_request' && | ||
( | ||
github.event_name == 'push' || | ||
github.event.pull_request.head.repo.full_name == github.repository | ||
) && | ||
!contains(github.event.head_commit.message, 'skip fix') | ||
if: env.APPLY_FIXES_IF_PR == 'true' | ||
with: | ||
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} | ||
commit-message: "[MegaLinter] Apply linters automatic fixes" | ||
title: "[MegaLinter] Apply linters automatic fixes" | ||
labels: bot | ||
|
||
- name: Create PR output | ||
if: >- | ||
steps.ml.outputs.has_updated_sources == 1 && | ||
( | ||
env.APPLY_FIXES_EVENT == 'all' || | ||
env.APPLY_FIXES_EVENT == github.event_name | ||
) && | ||
env.APPLY_FIXES_MODE == 'pull_request' && | ||
( | ||
github.event_name == 'push' || | ||
github.event.pull_request.head.repo.full_name == github.repository | ||
) && | ||
!contains(github.event.head_commit.message, 'skip fix') | ||
if: env.APPLY_FIXES_IF_PR == 'true' | ||
run: | | ||
echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}" | ||
echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}" | ||
|
||
# Push new commit if applicable | ||
# (for now works only on PR from same repository, not from forks) | ||
- name: Prepare commit | ||
if: >- | ||
steps.ml.outputs.has_updated_sources == 1 && | ||
( | ||
env.APPLY_FIXES_EVENT == 'all' || | ||
env.APPLY_FIXES_EVENT == github.event_name | ||
) && | ||
env.APPLY_FIXES_MODE == 'commit' && | ||
github.ref != 'refs/heads/main' && | ||
( | ||
github.event_name == 'push' || | ||
github.event.pull_request.head.repo.full_name == github.repository | ||
) && | ||
!contains(github.event.head_commit.message, 'skip fix') | ||
if: env.APPLY_FIXES_IF_COMMIT == 'true' | ||
run: sudo chown -Rc $UID .git/ | ||
|
||
- name: Commit and push applied linter fixes | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
if: >- | ||
steps.ml.outputs.has_updated_sources == 1 && | ||
( | ||
env.APPLY_FIXES_EVENT == 'all' || | ||
env.APPLY_FIXES_EVENT == github.event_name | ||
) && | ||
env.APPLY_FIXES_MODE == 'commit' && | ||
github.ref != 'refs/heads/main' && | ||
( | ||
github.event_name == 'push' || | ||
github.event.pull_request.head.repo.full_name == github.repository | ||
) && | ||
!contains(github.event.head_commit.message, 'skip fix') | ||
if: env.APPLY_FIXES_IF_COMMIT == 'true' | ||
with: | ||
branch: >- | ||
${{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already in https://github.com/oxsecurity/megalinter/pull/3032/files#diff-f339c840e1de23f5dc489a9282db9dff6a8bcade192e4f4d7edb239548320552R285-R286