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

ci: add lint actions #19

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/linters/lint-commit-message.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "✒ Lint commit messages with commitlint"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
commit-lint:
name: "✒ lint commit message"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
17 changes: 17 additions & 0 deletions .github/workflows/linters/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "✒ Lint pull request title"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
semantic-pull-request:
name: "✒ Lint PR title"
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/linters/lint-target-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "✒ Close Pull Request if it targets main"

on:
pull_request_target:
types: [opened]
branches:
- main
- master

jobs:
run:
name: "✒ Lint target branch"
runs-on: ubuntu-latest
steps:
- name: Assign variable
id: secret
run: echo '::set-output name=secret::${{secrets.MERGE_ACCEPTED_USERS}}'
- uses: superbrothers/close-pull-request@v3
if: ${{ !contains(steps.secret.outputs.secret, GITHUB_ACTOR) }}
with:
comment: "Hey! Please do not to pull request to main branch! Please try request to develop instead!"
24 changes: 24 additions & 0 deletions .github/workflows/linters/reviewdog/lint-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "✑ Lint action with actionlint using reviewdog"

on:
pull_request_target:
types:
- opened
- synchronize
branches:
- develop
paths:
- ".github/workflows/**/*.yml"
- ".github/workflows/**/*.yaml"

jobs:
actionlint:
name: "✒ lint actions"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: reviewdog/action-actionlint@v1
with:
github_token: ${{ secrets.KIRARI_TOKEN }}
reporter: github-pr-review
level: error
27 changes: 27 additions & 0 deletions .github/workflows/linters/reviewdog/lint-dockerfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "✒ Lint dockerfile with hadolint using reviewdog"

on:
pull_request_target:
types:
- opened
- synchronize
branches:
- develop
paths:
- '**/Dockerfile'
- '*_Dockerfile'
- 'Dockerfile_*'

jobs:
hadolint:
name: "✒ lint dockerfile"
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v1
- name: hadolint
uses: reviewdog/action-hadolint@v1
with:
github_token: ${{ secrets.KIRARI_TOKEN }}
reporter: github-pr-check
Dosugamea marked this conversation as resolved.
Show resolved Hide resolved
level: error
26 changes: 26 additions & 0 deletions .github/workflows/linters/reviewdog/lint-dotenv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "✒ Lint dotenv with dotenv-linter using reviewdog"

on:
pull_request_target:
types:
- opened
- synchronize
branches:
- develop
paths:
- '**/.env_*'
- '**/*.env'
- '.env_*'

jobs:
dotenv-linter:
name: "✒ lint dotenv"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run dotenv-linter with code suggestions
uses: dotenv-linter/action-dotenv-linter@v2
with:
github_token: ${{ secrets.KIRARI_TOKEN }}
reporter: github-code-suggestions
level: error
23 changes: 23 additions & 0 deletions .github/workflows/linters/reviewdog/lint-markdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "✒ Lint markdown files with markdownlint using reviewdog"

on:
pull_request_target:
types:
- opened
- synchronize
branches:
- develop
paths:
- '**/*.md'

jobs:
markdownlint:
name: "✒ lint markdown"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: markdownlint
uses: reviewdog/action-markdownlint@v0
with:
github_token: ${{ secrets.KIRARI_TOKEN }}
reporter: github-pr-check
Dosugamea marked this conversation as resolved.
Show resolved Hide resolved
27 changes: 27 additions & 0 deletions .github/workflows/linters/reviewdog/lint-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "✒ Lint style files with stylelint using reviewdog"

on:
pull_request_target:
types:
- opened
- synchronize
branches:
- develop
paths:
- '**/*.css'
- '**/*.scss'

jobs:
stylelint:
name: "✒ lint css/scss"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: stylelint
uses: reviewdog/action-stylelint@v1
with:
github_token: ${{ secrets.KIRARI_TOKEN }}
reporter: github-pr-review
stylelint_input:
- '**/*.css'
- '**/*.scss'
27 changes: 27 additions & 0 deletions .github/workflows/linters/reviewdog/lint-text.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "✒ Lint text files with textlint using reviewdog"

on:
pull_request_target:
types:
- opened
- synchronize
branches:
- develop
paths:
- 'docs/*.md'

jobs:
reviewdog-github-check:
name: "✒ lint text"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: textlint-github-pr-review
uses: tsuyoshicho/action-textlint@v3
with:
github_token: ${{ secrets.KIRARI_TOKEN }}
reporter: github-pr-review
textlint_flags: "docs/**"
25 changes: 25 additions & 0 deletions .github/workflows/linters/reviewdog/lint-yaml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "✒ Lint yaml files with yamllint using reviewdog"

on:
pull_request_target:
types:
- opened
- synchronize
branches:
- develop
paths:
- "**.yml"
- "**.yaml"

jobs:
yamllint:
name: "✒ lint yaml"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: yamllint
uses: reviewdog/action-yamllint@v1
with:
github_token: ${{ secrets.KIRARI_TOKEN }}
reporter: github-pr-review
yamllint_flags: '/'
24 changes: 24 additions & 0 deletions .github/workflows/linters/reviewdog/python/lint-black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "✑ Lint python file with black using reviewdog"

on:
pull_request_target:
types:
- opened
- synchronize
branches:
- develop
paths:
- '**/*.py'

jobs:
lint_black:
name: "✒ lint py with black"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: reviewdog/action-black@v2
with:
github_token: ${{ secrets.KIRARI_TOKEN }}
black_args: "--line-length=88"
reporter: github-pr-review
level: error
31 changes: 31 additions & 0 deletions .github/workflows/linters/reviewdog/python/lint-flake8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "✑ Lint python file with flake8 using reviewdog"

on:
pull_request_target:
types:
- opened
- synchronize
branches:
- develop
paths:
- '**/*.py'

jobs:
lint_flake8:
name: "✒ lint py with flake8"
runs-on: ubuntu-latest
name: Lint
steps:
- name: Check out source repository
uses: actions/checkout@v2
- name: Set up Python environment
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: flake8 Lint
uses: reviewdog/action-flake8@v3
with:
github_token: ${{ secrets.KIRARI_TOKEN }}
flake8_args: "--max-line-length=88"
reporter: github-pr-review
level: error
24 changes: 24 additions & 0 deletions .github/workflows/linters/reviewdog/python/lint-mypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "✑ Lint python file with mypy using reviewdog"

on:
pull_request_target:
types:
- opened
- synchronize
branches:
- develop
paths:
- '**/*.py'

jobs:
lint_mypy:
name: "✒ lint py with mypy"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: tsuyoshicho/action-mypy@v3
with:
github_token: ${{ secrets.KIRARI_TOKEN }}
reporter: github-pr-review
level: error
workdir: src
58 changes: 58 additions & 0 deletions .github/workflows/linters/scan-with-codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "🔒 Scan with CodeQL"

on:
push:
branches: [ "develop", "main", "master" ]
pull_request:
branches: [ "develop", "main", "master" ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python', 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2