-
Notifications
You must be signed in to change notification settings - Fork 1
131 lines (115 loc) · 3.67 KB
/
CI-linter.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---
name: CI-linting
on:
pull_request:
types: [opened, synchronize]
schedule:
- cron: "0 0 * * *"
jobs:
linting:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -leo pipefail {0}
permissions:
contents: read
packages: read
statuses: write
steps:
- name: checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Check for non-ASCII characters
run: |
output=$(find . -type f \
\( -name "*.py" -o -name "*.rst" -o -name "*.yml" -o -name "*.toml" \) \
-exec perl -ne 'print if /[^[:ascii:]]/' {} \;)
if [ -n "$output" ]; then
echo "Non-ASCII characters found in documentation."
exit 1
fi
- name: install packages not included in super-linter
run: |
pip install validate-pyproject restructuredtext-lint
- name: pyproject.toml
run: |
validate-pyproject pyproject.toml
# RST linter
# Note: unclear how to suppress error messages
# (use grep -v in this case)
# - name: restructuredtext-lint
# run: |
# rst-lint README.rst docs/source |
# grep -v "Unknown directive type" |
# grep -v "Unknown interpreted text role" |
# grep -v "Cannot analyze code. Pygments package not found."
- name: Check whether the citation metadata from CITATION.cff is valid
uses: citation-file-format/[email protected]
with:
args: "--validate"
- name: yaml_config used by super-linter
run: |
# TODO - very large line length
echo 'rules:' > yaml_config.yaml
echo ' line-length:' >> yaml_config.yaml
echo ' max: 250' >> yaml_config.yaml
# Dependencies required to avoid errors
# reported by linters
- name: Install mamba dependencies
uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment.yml
init-shell: bash
- name: Lint Code Base
uses: super-linter/super-linter@v5
env:
VALIDATE_ALL_CODEBASE: true
# github actions
VALIDATE_GITHUB_ACTIONS: true
# yaml
VALIDATE_YAML: true
YAML_CONFIG_FILE: yaml_config.yaml
YAML_ERROR_ON_WARNING: false
# pylint
VALIDATE_PYTHON_PYLINT: true
PYTHON_PYLINT_CONFIG_FILE: pyproject.toml
# isort
VALIDATE_PYTHON_ISORT: true
PYTHON_ISORT_CONFIG_FILE: pyproject.toml
# flake8
VALIDATE_PYTHON_FLAKE8: true
# black
VALIDATE_PYTHON_BLACK: true
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
# markdown
VALIDATE_MARKDOWN: true
# docker
VALIDATE_DOCKERFILE_HADOLINT: true
# copy and paste
VALIDATE_JSCPD_ALL_CODEBASE: true
# .env file
VALIDATE_ENV: true
# language
VALIDATE_NATURAL_LANGUAGE: true
# bash
VALIDATE_BASH: true
# path for linter rules
LINTER_RULES_PATH: ./
# create a log file
CREATE_LOG_FILE: true
LOG_FILE: superlinter.log
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Upload super-linter log file
# and keep it for 5 days
- name: Archive production artifacts
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: super-linter reports
path: |
superlinter.log
retention-days: 5