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

Ensure XPPM/YPPM consistency on CI #42

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ jobs:
- name: Install pre-commit
run: |
pip install pre-commit

- name: Run lint via pre-commit
run: |
pre-commit run --all-files

- name: Check advection code consistency
run: |
./.github/workflows/scripts/ensure_xppm_yppm_consistency.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#!/bin/bash
#
# Script to convert xppm.py/xtp_u.py into yppm/ytp_v.py. Can be deleted once we
# have a way to use the same codebase for x-direction and y-direction advection.
# Script to automatically convert `xppm.py` and `xtp_u.py` into `yppm.py` and
# `ytp_v.py` respectively. We use it as part of the linting workflow in the CI
# to ensure these files stay in sync.
#
# This script (and the corresponding linting workflow) can be deleted once we
# have a way to use the same codebase for x-direction and y-direction advection.

set -e -x
set -e

# Copy XPPM codes into YPPM files
cp pyFV3/stencils/xppm.py pyFV3/stencils/yppm.py
cp pyFV3/stencils/xtp_u.py pyFV3/stencils/ytp_v.py

# Fixup YPPM code
for fname in pyFV3/stencils/yppm.py pyFV3/stencils/ytp_v.py
do
sed -i 's/ub/vb/g' $fname
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/scripts/ensure_xppm_yppm_consistency.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Call the automatic conversion
./.github/workflows/scripts/convert_xppm_yppm.sh

# Check for uncommitted changes in the working tree
if [ -n "$(git status --porcelain)" ]; then
echo "It looks like x-direction and y-direction advection are out of sync. We found uncommitted"
echo "changes in working tree after YPPM was generated from XPPM sources. Please ensure to make"
echo "symmetrical changes to XPPM and YPPM codes."
echo ""
echo "If this is a false positive, please fix \".github/workflows/scripts/convert_xppm_yppm.sh\""
echo "or re-evaluate the need for this part of the linting workflow."
echo ""
echo "git status"
echo "----------"
git status
echo ""
echo "git diff"
echo "--------"
git --no-pager diff
echo ""

exit 1
else
echo "XPPM and YPPM are in sync."
fi