test: add new tests and refactoring #4143
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: MegaLinter | |
on: | |
pull_request: | |
env: # Comment env block if you don't 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) | |
APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all) | |
APPLY_FIXES_MODE: pull_request # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request) | |
concurrency: | |
group: ${{ github.ref }}-${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
megalinter: | |
name: Megalinter | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
steps: | |
# Git Checkout | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: MegaLinter | |
id: ml | |
uses: oxsecurity/megalinter@v8 | |
- name: Archive production artifacts | |
if: success() || failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Mega-Linter reports | |
path: | | |
megalinter-reports | |
mega-linter.log | |
overwrite: true | |
- uses: crazy-max/ghaction-import-gpg@v3 | |
if: failure() && steps.ml.outputs.has_updated_sources == 1 | |
id: import_gpg | |
with: | |
gpg-private-key: ${{ secrets.HYP_BOT_GPG_PRIVATE }} | |
passphrase: ${{ secrets.HYP_BOT_GPG_PASSWORD }} | |
git-user-signingkey: true | |
git-commit-gpgsign: true | |
git_config_global: true | |
git_tag_gpgsign: true | |
# Create pull request if applicable (for now works only on PR from same repository, not from forks) | |
- name: Create Pull Request with applied fixes | |
id: cpr | |
if: failure() && 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') | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
base: ${{ github.head_ref }} | |
branch-suffix: short-commit-hash | |
commit-message: "style: apply linters automatic fixes" | |
title: "style: apply linters automatic fixes" | |
signoff: true | |
committer: "Hyperledger Bot <hyperledger-bot@hyperledger.org>" | |
author: "Hyperledger Bot <hyperledger-bot@hyperledger.org>" | |
- name: Create PR output | |
if: failure() && 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') | |
run: | | |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | |
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |