Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub workflows to check black, pylint, git-fleximod #2964

Open
wants to merge 25 commits into
base: b4b-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
935cd12
Add fleximod_test workflow.
samsrabin Feb 14, 2025
6bea8f1
Update FATES URL.
samsrabin Feb 14, 2025
bacb056
Add pylint workflow
samsrabin Feb 14, 2025
369a469
Name fix in fleximod_test workflow.
samsrabin Feb 14, 2025
9586eed
Add versions of python for pylint testing.
samsrabin Feb 14, 2025
d9160f9
Disable fail-fast for pylint workflow.
samsrabin Feb 14, 2025
e26f717
Remove --check from pylint testing.
samsrabin Feb 14, 2025
010b938
Add black_multi_python workflow.
samsrabin Feb 14, 2025
d6abeda
Fix --config path for multi-python black check.
samsrabin Feb 14, 2025
0c7b07f
Add Python 3.7.9 to black_multi_python workflow.
samsrabin Feb 14, 2025
9f0b2ac
Print diffs in black_multi_python workflow,
samsrabin Feb 14, 2025
a975ad2
Add job to black_multi_python that works like black.yml.
samsrabin Feb 14, 2025
7819586
Replace non-working black-check-multi-python job.
samsrabin Feb 14, 2025
dc998ec
Move multi-python capability into old black.yml.
samsrabin Feb 14, 2025
ab04d8f
Add --diff to black check workflow.
samsrabin Feb 14, 2025
47ad185
Add python 3.7 to pylint workflow.
samsrabin Feb 14, 2025
8969088
Change that to 3.7.9.
samsrabin Feb 14, 2025
ae6c5b2
Try bumping pylint workflow setup-python version to fix 3.7.9.
samsrabin Feb 14, 2025
60d4d98
Move 3.7.9 pylint check to ubuntu-20.04
samsrabin Feb 14, 2025
665e642
Pylint workflow now fails on complaints.
samsrabin Feb 14, 2025
b5752fa
pip install requirements in pylint workflow.
samsrabin Feb 14, 2025
5408f74
pylint workflow > 3.7.9 now ignores warning about useless option for …
samsrabin Feb 14, 2025
c520d31
Lock pylint to version in ctsm_pylib.
samsrabin Feb 14, 2025
097e2b3
Restrict pylint workflow to Python versions that work.
samsrabin Feb 14, 2025
bcb398d
Restrict running of black and pylint workflows.
samsrabin Feb 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,29 @@ name: black check on push and PR
#
# Run the python formatting in check mode
#
on: [push, pull_request]
on:
push:
paths:
- 'python/**'
- 'cime_config/SystemTests/**'
- 'cime_config/buildlib/**'
- 'cime_config/buildnml/**'
- '.github/workflows/black.yml'
pull_request:
paths:
- 'python/**'
- 'cime_config/SystemTests/**'
- 'cime_config/buildlib/**'
- 'cime_config/buildnml/**'
- '.github/workflows/black.yml'

jobs:
black-check:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.7.9", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
# Checkout the code
- uses: actions/checkout@v2
Expand All @@ -15,23 +33,23 @@ jobs:
with:
# Use options and version identical to the conda environment
# Using pyproject.toml makes sure this testing is consistent with our python directory testing
options: "--check --config python/pyproject.toml"
options: "--check --diff --config python/pyproject.toml"
src: "./python"
# Version should be coordinated with the ctsm_pylib conda environment under the python directory
version: "22.3.0"
# Actions identical to above for each directory and source file we need to check (arrays aren't allowed for src: field)
- uses: psf/black@stable
with:
options: "--check --config python/pyproject.toml"
options: "--check --diff --config python/pyproject.toml"
src: "./cime_config/SystemTests"
version: "22.3.0"
- uses: psf/black@stable
with:
options: "--check --config python/pyproject.toml"
options: "--check --diff --config python/pyproject.toml"
src: "./cime_config/buildlib"
version: "22.3.0"
- uses: psf/black@stable
with:
options: "--check --config python/pyproject.toml"
options: "--check --diff --config python/pyproject.toml"
src: "./cime_config/buildnml"
version: "22.3.0"
31 changes: 31 additions & 0 deletions .github/workflows/fleximod_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: git-fleximod test
#
# Test git-fleximod update and cleanliness
# Based closely on workflow from CESM repo
#
on: [push, pull_request]

jobs:
fleximod-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# oldest supported and latest supported
python-version: ["3.7", "3.x"]
steps:
- id: checkout-CTSM
uses: actions/checkout@v4
- id: run-fleximod
run: |
$GITHUB_WORKSPACE/bin/git-fleximod update
echo
echo "Update complete, checking status"
echo
$GITHUB_WORKSPACE/bin/git-fleximod test
- id: check-cleanliness
run: |
echo
echo "Checking if git fleximod matches expected externals"
echo
git diff --exit-code
61 changes: 61 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: pylint check on push and PR
#
# Run the pylint formatting
#
on:
push:
paths:
- 'python/ctsm/**'
- 'python/requirements.txt'
- '.github/workflows/pylint.yml'
pull_request:
paths:
- 'python/ctsm/**'
- 'python/requirements.txt'
- '.github/workflows/pylint.yml'

jobs:
# Disabled pylint-check-old because 3.7.9 requires netCDF to be manually installed first
# pylint-check-old:
# runs-on: ubuntu-20.04
# strategy:
# fail-fast: false
# matrix:
# python-version: ["3.7.9"]
# steps:
# - uses: actions/checkout@v4
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r python/requirements.txt
# - name: Analysing the code with pylint
# run: |
# cd python
# pylint --rcfile=ctsm/.pylintrc ctsm
pylint-check:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Python 3.8 fails because GEOS C headers aren't installed
# Our pylint (2.8.3) is incompatible with Python > 3.10
# python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r python/requirements.txt
- name: Analysing the code with pylint
run: |
cd python
pylint --disable=R0022 --rcfile=ctsm/.pylintrc ctsm
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ url = https://github.com/NGEET/fates
fxtag = sci.1.80.11_api.37.0.0
fxrequired = AlwaysRequired
# Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed
fxDONOTUSEurl = https://github.com/NCAR/fates-release
fxDONOTUSEurl = https://github.com/NGEET/fates

[submodule "cism"]
path = components/cism
Expand Down
18 changes: 14 additions & 4 deletions python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
Requirements for testing:

- If using python < 3.3, requires the mock library (this is available in
the standard library in python 3.3+)
pandas
tqdm
scipy
netcdf4
requests
packaging
numpy
xarray
xesmf
numba
pylint==2.8.3
black
cartopy
matplotlib