CI-linting #2351
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: CI-linting | |
on: | |
workflow_dispatch: | |
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 | |
with: | |
# super-linter needs the full git history to get the | |
# list of files that changed across commits | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
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:]]/ && !/latin/i' {} \;) | |
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 | |
- name: pyproject.toml | |
run: | | |
validate-pyproject pyproject.toml | |
- name: Check whether the citation metadata from CITATION.cff is valid | |
uses: citation-file-format/[email protected] | |
with: | |
args: "--validate" | |
# Dependencies required to avoid errors | |
# reported by linters | |
- name: Install mamba dependencies | |
uses: mamba-org/setup-micromamba@v2 | |
with: | |
environment-file: environment.yml | |
init-shell: bash | |
- name: Python dependencies | |
run: | | |
pip install -e '.[tests,dev,doc]' | |
pip install pylint | |
- name: pylint | |
run: | | |
git ls-files 'src/simtools/*.py' | xargs pylint -v | |
- name: Pre-commit | |
run: | | |
pre-commit run --all-files | |
- name: Lint Code Base | |
uses: super-linter/super-linter@v7 | |
env: | |
VALIDATE_ALL_CODEBASE: false | |
# docker | |
VALIDATE_DOCKERFILE_HADOLINT: 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 }} |