Skip to content

Commit

Permalink
setting up megalinter
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbazhenoff committed Mar 17, 2024
1 parent 2fd8c5f commit e5cb2e1
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 202 deletions.
39 changes: 0 additions & 39 deletions .github/linters/.devskim.json

This file was deleted.

124 changes: 4 additions & 120 deletions .github/workflows/mega-liner.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
---

name: MegaLinter
on:
# Comment this line to trigger action only on pull-requests
# (not recommended if you don't pay for GH Actions)
on: # yamllint disable-line rule:truthy
push:
pull_request:
branches:
- main
- master
permissions: read-all
# Comment env block if you do not want to apply fixes
env:
# Apply linter fixes configuration
#
# When active, APPLY_FIXES must also be defined as environment variable
# (in github/workflows/mega-linter.yml or other CI tool)
APPLY_FIXES: all
# Decide which event triggers application of fixes in a commit or a PR
# (pull_request, push, all)
APPLY_FIXES_EVENT: pull_request
# If APPLY_FIXES is used, defines if the fixes are directly committed (commit)
# or posted in a PR (pull_request)
APPLY_FIXES_MODE: commit

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
Expand All @@ -32,125 +17,24 @@ jobs:
megalinter:
name: MegaLinter
runs-on: ubuntu-latest
# Give the default GITHUB_TOKEN write permission to commit and push, comment
# issues & post new PR; remove the ones you do not need
permissions:
contents: write
contents: read
issues: write
pull-requests: write
pull-requests: read
statuses: write

steps:

# Git Checkout
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}

# If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to
# improve performance
fetch-depth: 0

# MegaLinter
- name: MegaLinter

# You can override MegaLinter flavor used to have faster performances
uses: oxsecurity/megalinter@latest
id: ml
# All available variables are described in documentation
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
#
# To validate the entire codebase, set to:
# VALIDATE_ALL_CODEBASE: true
#
# To validate only diff with main, set to:
# VALIDATE_ALL_CODEBASE: >-
# ${{
# github.event_name == 'push' &&
# contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref)
# }}
VALIDATE_ALL_CODEBASE: true
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

# Uncomment to disable copy-paste and spell checks
# DISABLE: COPYPASTE,SPELL

# Upload MegaLinter artifacts
- name: Archive production artifacts
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: MegaLinter reports
path: |
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
)
}}" >> "${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}"

Check failure on line 40 in .github/workflows/mega-liner.yml

View workflow job for this annotation

GitHub Actions / MegaLinter

40:1 [empty-lines] too many blank lines (1 > 0)
# 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@v6
id: cpr
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: 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: 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: env.APPLY_FIXES_IF_COMMIT == 'true'
with:
branch: >-
${{
github.event.pull_request.head.ref ||
github.head_ref ||
github.ref
}}
commit_message: "[MegaLinter] Apply linters fixes"
commit_user_name: megalinter-bot
commit_user_email: nicolas.vuillamy@ox.security
33 changes: 0 additions & 33 deletions .github/workflows/super-linter.yml

This file was deleted.

6 changes: 5 additions & 1 deletion .github/workflows/wiki-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ name: Wiki CI
on: # yamllint disable-line rule:truthy
push:
branches:
- '**'
- main
pull_request:
branches:
- main
- master
permissions: read-all

env:
Expand Down
7 changes: 2 additions & 5 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---

REPOSITORY_DEVSKIM_PRE_COMMANDS:
- command: git config --global --add safe.directory /github/workspace/.git
cwd: "workspace"

SPELL_CSPELL_FILTER_REGEX_EXCLUDE: README_RUS.md
YAML_V8R_FILTER_REGEX_EXCLUDE: .+-lint.yml
DISABLE_LINTERS:
- REPOSITORY_KICS
- REPOSITORY_DEVSKIM
- SPELL_CSPELL
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

- Send report via [Telegram messenger](https://telegram.org/) using
[Telegram Bot](https://core.telegram.org/bots/tutorial) has been added.
- CI improvements: automated Wiki Build has been added.
- CI improvements:
- Automated Wiki Build has been added.
- Switched from [Super-Linter](https://github.com/super-linter/super-linter)
to [MegaLinter](https://megalinter.io/).

## [1.0.0](https://github.com/alexanderbazhenoff/jenkins-universal-wrapper-pipeline/pull/1) (2024-02-24)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Fast and easy way to create Jenkins pipelines through yaml configuration files.
<!-- markdown-link-check-disable -->
[![Super-Linter](https://github.com/alexanderbazhenoff/jenkins-universal-wrapper-pipeline/actions/workflows/super-linter.yml/badge.svg?branch=main)](https://github.com/marketplace/actions/super-linter)
[![MegaLinter](https://github.com/alexanderbazhenoff/jenkins-universal-wrapper-pipeline/actions/workflows/mega-linter.yml/badge.svg?branch=main)](https://megalinter.io/)
[![Wiki CI](https://github.com/alexanderbazhenoff/jenkins-universal-wrapper-pipeline/actions/workflows/wiki-ci.yml/badge.svg?branch=main)](https://github.com/alexanderbazhenoff/jenkins-universal-wrapper-pipeline/wiki)
[![Release CI](https://github.com/alexanderbazhenoff/jenkins-universal-wrapper-pipeline/actions/workflows/release-ci.yml/badge.svg?branch=main)](CHANGELOG.md)
[![GitHub Release](https://img.shields.io/github/v/release/alexanderbazhenoff/jenkins-universal-wrapper-pipeline)](https://github.com/alexanderbazhenoff/jenkins-universal-wrapper-pipeline/releases)
Expand Down Expand Up @@ -52,7 +52,7 @@ actions then action description what each of them should do.
run them through the command-line.
3. This pipeline requires [jenkins shared library](https://github.com/alexanderbazhenoff/jenkins-shared-library)
connection.
4. [AnsiColor Jenkins plugin](https://plugins.jenkins.io/ansicolor/) for colour console output.
4. [AnsiColor Jenkins plugin](https://plugins.jenkins.io/ansicolor/) for color console output.
5. To run ansible inside a wrapper plugin you may need to install
[Ansible Jenkins plugin](https://plugins.jenkins.io/ansible/) (optional, not required by default).

Expand Down
2 changes: 1 addition & 1 deletion README_RUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Быстрый и простой способ создавать Jenkins pipeline'ы через конфигурационные yaml файлы.
<!-- markdown-link-check-disable -->
[![Super-Linter](https://github.com/alexanderbazhenoff/jenkins-universal-wrapper-pipeline/actions/workflows/super-linter.yml/badge.svg?branch=main)](https://github.com/marketplace/actions/super-linter)
[![MegaLinter](https://github.com/alexanderbazhenoff/jenkins-universal-wrapper-pipeline/actions/workflows/mega-linter.yml/badge.svg?branch=main)](https://megalinter.io/)
[![Wiki CI](https://github.com/alexanderbazhenoff/jenkins-universal-wrapper-pipeline/actions/workflows/wiki-ci.yml/badge.svg?branch=main)](https://github.com/alexanderbazhenoff/universal-wrapper-pipeline-settings/wiki)
[![Release CI](https://github.com/alexanderbazhenoff/jenkins-universal-wrapper-pipeline/actions/workflows/release-ci.yml/badge.svg?branch=main)](CHANGELOG.md)
[![GitHub Release](https://img.shields.io/github/v/release/alexanderbazhenoff/jenkins-universal-wrapper-pipeline)](https://github.com/alexanderbazhenoff/jenkins-universal-wrapper-pipeline/releases)
Expand Down

0 comments on commit e5cb2e1

Please sign in to comment.