-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (81 loc) · 2.56 KB
/
static-analysis.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
name: static analysis
on:
pull_request:
branches:
- develop
- main
- release/**
- feature/**
- hotfix/**
push:
branches:
- develop
- main
- release/**
- feature/**
- hotfix/**
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
source_dir: plate_simulation
jobs:
pre-commit:
name: pre-commit
strategy:
fail-fast: false
runs-on: ubuntu-latest
env:
SKIP: pylint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: capture modified files
if: github.event_name == 'pull_request'
run: >-
git fetch --deepen=500 origin ${{github.base_ref}}
&& echo "FILES_PARAM=$(
git diff --diff-filter=AM --name-only refs/remotes/origin/${{github.base_ref}}... -- | grep -E "^(${source_dir}|tests)/.*\.py$" | xargs
)" >> $GITHUB_ENV
- name: Run pre-commit on modified files
if: github.event_name == 'pull_request' && env.FILES_PARAM
uses: pre-commit/[email protected]
with:
extra_args: --hook-stage push --files ${{ env.FILES_PARAM }}
- name: Run pre-commit on all files
if: github.event_name == 'push'
uses: pre-commit/[email protected]
with:
extra_args: --hook-stage push --all-files
pylint:
name: pylint
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
env:
PYTHONUTF8: 1
CONDA_CHANNEL_PRIORITY: strict
PIP_NO_DEPS: 1 # all dependencies are installed from conda
CONDA_LOCK_ENV_FILE: environments/py-3.10-linux-64-dev.conda.lock.yml
steps:
- uses: actions/checkout@v4
- name: Setup conda env
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ${{ env.CONDA_LOCK_ENV_FILE }}
environment-name: linter_env
cache-downloads: true
- name: capture modified files
if: github.event_name == 'pull_request'
run: >-
git fetch --deepen=500 origin ${{github.base_ref}}
&& echo "FILES_PARAM=$(
git diff --diff-filter=AM --name-only refs/remotes/origin/${{github.base_ref}}... -- | grep -E "^(${source_dir}|tests)/.*\.py$" | xargs
)" >> $GITHUB_ENV
- name: Run pylint on modified files
if: github.event_name == 'pull_request' && env.FILES_PARAM
run: pylint $FILES_PARAM
- name: Run pylint on all files
if: github.event_name == 'push'
run: pylint $source_dir tests