From 6003c4852199159d769d69bb1455eaa5cc474523 Mon Sep 17 00:00:00 2001 From: AtomicFS Date: Tue, 19 Nov 2024 14:19:29 +0100 Subject: [PATCH] feat(ci): add linters and stuff Signed-off-by: AtomicFS --- .cspell.json | 183 +++++++++++++++++++++++++++++++++++++ .editorconfig | 28 ++++++ .github/dependabot.yml | 13 +++ .github/labeler.yml | 28 ++++++ .github/workflows/lint.yml | 52 +++++++++++ .mega-linter.yml | 17 ++++ 6 files changed, 321 insertions(+) create mode 100644 .cspell.json create mode 100644 .editorconfig create mode 100644 .github/dependabot.yml create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .mega-linter.yml diff --git a/.cspell.json b/.cspell.json new file mode 100644 index 0000000..7eb627b --- /dev/null +++ b/.cspell.json @@ -0,0 +1,183 @@ +{ + "ignorePaths": [ + "**/*.defconfig", + "**/.git/**", + "**/node_modules/**", + "**/vscode-extension/**", + ".cspell.json", + ".editorconfig", + ".flake8", + ".github/dependabot.yml", + ".github/workflows/documentation-pages.yml", + ".gitignore", + ".goreleaser.yaml", + ".mega-linter.yml", + ".pylintrc", + ".ruff.toml", + ".trivy.yaml", + ".vscode", + "CHANGELOG.md", + "LICENSE", + "Taskfile.yml", + "docker/**", + "docs/book.toml", + "docs/mdbook-admonish.css", + "docs/theme/index.hbs", + "docs/theme/pagetoc.css", + "docs/theme/pagetoc.js", + "go.mod", + "go.sum", + "megalinter", + "package-lock.json", + "pyproject.toml", + "report", + "requirements.txt", + "tests/**" + ], + "language": "en", + "noConfigSearch": true, + "words": [ + "BOOTLOADER", + "BUILDGCC", + "CPUS", + "GOARCH", + "HEALTHCHECK", + "Hadolint", + "IPXE", + "NOTSET", + "REPOPATH", + "TARGETARCH", + "TOOLSDIR", + "Taskfile", + "acpica", + "addinivalue", + "addoption", + "automerge", + "autopep", + "blkio", + "bsdmainutils", + "cbfstool", + "clusterfuck", + "cmds", + "cocogitto", + "commitlint", + "composefile", + "coreboot", + "coreinfo", + "covermode", + "coverprofile", + "cpio", + "crossgcc", + "daggerci", + "defconfig", + "delenv", + "dirpath", + "distclean", + "dockerfile", + "dockerfiles", + "dooper", + "dotconfig", + "dpkg", + "edkii", + "elif", + "emeraldlake", + "exitcode", + "githubaction", + "githubactions", + "gocyclo", + "golangci", + "gorecurcopy", + "goreleaser", + "iasl", + "ifdtool", + "inargs", + "iucode", + "kbuild", + "kconfig", + "kernelbuild", + "levelname", + "libelf", + "libncurses", + "libnss", + "logdir", + "mainboard", + "mainboarddir", + "markdownlint", + "megalinter", + "menuconfig", + "modifyitems", + "mountpoint", + "multilib", + "nasm", + "naturalsize", + "nolint", + "noninteractive", + "nonosi", + "nproc", + "nvramcui", + "olddefconfig", + "opencontainers", + "oxsecurity", + "pacman", + "pwsh", + "pyaload", + "pylint", + "pytest", + "rdparty", + "rootdir", + "runslow", + "rustup", + "savedefconfig", + "seabios", + "setenv", + "sethvargo", + "shellcheck", + "skipframes", + "sloglint", + "startswith", + "stmsg", + "testregex", + "textfile", + "tianocore", + "tinyconfig", + "tzdata", + "uefi", + "uroot", + "vmlinux", + "wagoid", + "workdir", + "worktree", + "xgcc" + ], + "ignoreWords": [ + "Eeuo", + "Kengo", + "Ovmf", + "TODA", + "aarch", + "agrc", + "alecthomas", + "anyio", + "bugbundle", + "coveragerc", + "dawidd", + "defaultsh", + "dorny", + "dumpversion", + "edksetup", + "genqlient", + "gnueabi", + "heimdalr", + "hhmmss", + "htmlcov", + "ldflags", + "mypy", + "opengrabeso", + "prettytable", + "stretchr", + "unxz", + "wholename", + "xvzf" + ], + "version": "0.2" +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..aea7b2d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,28 @@ +# EditorConfig: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +charset = utf-8 +indent_style = tab + +[*.py] +indent_style = space +indent_size = 4 + +[*.{json,yml,yaml,js,mjs,css}] +indent_style = space +indent_size = 2 + +[Dockerfile] +indent_style = space +indent_size = 4 + +[{*.md,.pylintrc,index.hbs,LICENSE}] +indent_style = unset +indent_size = unset +generated_code = true + diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5157390 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +--- +version: 2 +updates: + - package-ecosystem: 'github-actions' + directory: '/' + schedule: + interval: 'daily' + time: '00:00' + groups: + github: + update-types: + - 'minor' + - 'patch' diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..7099db9 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,28 @@ +bugfix: + - head-branch: + - '^fix' +github_actions: + - any: + - changed-files: + - any-glob-to-any-file: + - '.github/workflows/**' + - head-branch: + - '^ci' +coreboot: + - any: + - changed-files: + - any-glob-to-any-file: + - 'coreboot/**' +testing: + - any: + - changed-files: + - any-glob-to-any-file: + - '.cspell.json' + - '.mega-linter.yml' + - head-branch: + - '^test' +feature: + - any: + - head-branch: + - '^feat' + - '^feature' diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..4610f4a --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,52 @@ +--- +# Run linters + +name: lint +on: + pull_request: + pull_request_review: + types: ['submitted'] + merge_group: + push: + branches: ['main'] + tags: ['v*'] + +env: + APPLY_FIXES: none + APPLY_FIXES_EVENT: pull_request + APPLY_FIXES_MODE: commit +concurrency: + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + commit-lint: + runs-on: ubuntu-latest + if: ${{ ! (github.event_name == 'pull_request_review' && github.actor != 'github-actions[bot]') }} + # Skip if pull_request_review on PR not made by a bot + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Commit-Lint + uses: wagoid/commitlint-github-action@v6 + with: + configFile: .commitlint.config.mjs + megalinter: + runs-on: ubuntu-latest + if: ${{ ! (github.event_name == 'pull_request_review' && github.actor != 'github-actions[bot]') }} + # Skip if pull_request_review on PR not made by a bot + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: MegaLinter + uses: oxsecurity/megalinter/flavors/cupcake@v8 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VALIDATE_ALL_CODEBASE: true diff --git a/.mega-linter.yml b/.mega-linter.yml new file mode 100644 index 0000000..7ca84fd --- /dev/null +++ b/.mega-linter.yml @@ -0,0 +1,17 @@ +APPLY_FIXES: all +DISABLE: + - COPYPASTE +DISABLE_LINTERS: + - CSS_STYLELINT + - GO_GOLANGCI_LINT + - REPOSITORY_KICS + - SPELL_LYCHEE + - REPOSITORY_TRIVY +SHOW_ELAPSED_TIME: true +FILEIO_REPORTER: false + +# Spelling +SPELL_CSPELL_ANALYZE_FILE_NAMES: false + +# yaml v8r +YAML_V8R_DISABLE_ERRORS: true