Skip to content

Commit 098c1e9

Browse files
authored
feat: add lefthook, megalinter and update editorconfig (#270)
This change adds [LeftHook](https://lefthook.dev/) as a GitHub hook management tool alongside [MegaLinter](https://megalinter.io/) to lint all relevant files within the repository. For users that don't end up installing LeftHook for pre-commit hooks, megalinter picks up the necessary formatting changes and reports them. * feat: add lefthook, megalinter and update editorconfig * fix: lint commit ordering * refactor: adjust megalinter reporters * refactor: adjust description for cache domains * refactor: single - for passing options * refactor: add repo-specific fmt in megalinter pre-commands too
1 parent e7fc17a commit 098c1e9

25 files changed

+606
-487
lines changed

.editorconfig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ root = true
22

33
[*]
44
indent_style = space
5-
indent_size = 4
5+
indent_size = 2
66
trim_trailing_whitespace = true
77
end_of_line = lf
88
insert_final_newline = true
9+
10+
[*.md]
11+
indent_size = 0
12+
13+
[*.sh]
14+
indent_style = tab

.github/workflows/mega-linter.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# MegaLinter GitHub Action configuration file
2+
# More info at https://megalinter.io
3+
---
4+
name: MegaLinter
5+
6+
on:
7+
pull_request:
8+
branches:
9+
- master
10+
11+
env:
12+
GITHUB_STATUS_REPORTER: true
13+
14+
concurrency:
15+
group: ${{ github.ref }}-${{ github.workflow }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
megalinter:
20+
name: MegaLinter
21+
runs-on: ubuntu-latest
22+
23+
permissions:
24+
contents: write
25+
issues: write
26+
pull-requests: write
27+
28+
steps:
29+
- name: Checkout Code
30+
uses: actions/checkout@v4
31+
with:
32+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
33+
fetch-depth: 0
34+
35+
- name: MegaLinter
36+
uses: oxsecurity/megalinter@v8
37+
id: ml
38+
env:
39+
VALIDATE_ALL_CODEBASE: >-
40+
${{
41+
github.event_name == 'push' &&
42+
github.ref == 'refs/heads/master'
43+
}}
44+
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Archive production artifacts
48+
uses: actions/upload-artifact@v4
49+
if: success() || failure()
50+
with:
51+
name: MegaLinter reports
52+
include-hidden-files: "true"
53+
path: |
54+
megalinter-reports
55+
mega-linter.log

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
scripts/output
22
scripts/config.json
3+
megalinter-reports/

.lefthook.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pre-commit:
2+
parallel: true
3+
jobs:
4+
- name: sort cache domains
5+
run: jq ".cache_domains |= sort_by(.name)" {all_files} > {all_files}.tmp && mv {all_files}.tmp {all_files}
6+
glob: "cache_domains.json"
7+
8+
- name: sort cdns
9+
run: |
10+
for f in {all_files}; do
11+
sort -uo ${f} ${f}
12+
done
13+
env:
14+
LC_ALL: C
15+
glob: "*.txt"
16+
17+
- name: megalinter
18+
run: docker run --rm -e USER=$(id -u) -e GROUP=$(id -g) -v "$PWD:/tmp/lint" oxsecurity/megalinter:v8
19+
stage_fixed: true

.mega-linter.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Configuration file for MegaLinter
2+
#
3+
# See all available variables at https://megalinter.io/latest/config-file/ and in
4+
# linters documentation
5+
6+
APPLY_FIXES: all
7+
FLAVOR_SUGGESTIONS: false
8+
PRINT_ALPACA: false
9+
SHOW_ELAPSED_TIME: true
10+
11+
ENABLE:
12+
- ACTION
13+
- BASH
14+
- EDITORCONFIG
15+
- JSON
16+
- MARKDOWN
17+
- SPELL
18+
- YAML
19+
20+
DISABLE_LINTERS:
21+
- JSON_V8R
22+
- MARKDOWN_MARKDOWNLINT
23+
- SPELL_CSPELL
24+
- YAML_V8R
25+
26+
PRE_COMMANDS:
27+
- command: apk add --no-cache yq
28+
cwd: root
29+
- command: yq -i ".cache_domains |= sort_by(.name)" cache_domains.json
30+
cwd: workspace
31+
- command: |
32+
for f in *.txt; do
33+
sort -uo ${f} ${f}
34+
done
35+
cwd: workspace
36+
37+
POST_COMMANDS:
38+
- command: find . -user root -group root -exec chown ${USER}:${GROUP} {} \;
39+
cwd: workspace

blizzard.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
dist.blizzard.com
2-
dist.blizzard.com.edgesuite.net
1+
*.cdn.blizzard.com
32
blizzard.vo.llnwd.net
43
blzddist1-a.akamaihd.net
54
blzddist2-a.akamaihd.net
65
blzddist3-a.akamaihd.net
6+
cdn.blizzard.com
7+
dist.blizzard.com
8+
dist.blizzard.com.edgesuite.net
9+
edge.blizzard.top.comcast.net
710
level3.blizzard.com
811
nydus.battle.net
9-
edge.blizzard.top.comcast.net
10-
cdn.blizzard.com
11-
*.cdn.blizzard.com

0 commit comments

Comments
 (0)