Skip to content

Commit 206efce

Browse files
committed
Add .github/workflows/fortran-formatting.yaml
1 parent 1891310 commit 206efce

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Codee format Fortran
2+
3+
on:
4+
pull_request:
5+
6+
env:
7+
CODEE_VERSION: 2025.4.5
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
format:
15+
name: Check and fix Fortran formatting
16+
runs-on: ubuntu-22.04
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
ref: ${{ github.head_ref }}
24+
25+
- name: Get modified Fortran files
26+
#id: modified-files
27+
run: |
28+
MODIFIED_FILES=$(git diff --name-only --diff-filter=d origin/${{ github.base_ref }}...HEAD -- '*.f90' '*.F90' '*.f' '*.F')
29+
echo "MODIFIED_FILES=$MODIFIED_FILES" >> $GITHUB_ENV
30+
31+
- name: Install Codee
32+
if: env.MODIFIED_FILES != ''
33+
run: |
34+
echo "Installing Codee ${CODEE_VERSION} ..."
35+
wget https://codee.com/release/codee-${CODEE_VERSION}-linux-x86_64.tar.gz
36+
tar -xf codee-${CODEE_VERSION}-linux-x86_64.tar.gz
37+
38+
- name: Run `codee format` on modified files
39+
if: env.MODIFIED_FILES != ''
40+
run: |
41+
export PATH="${PWD}/codee-${CODEE_VERSION}-linux-x86_64/bin:${PATH}"
42+
codee format --accept-eula --verbose $MODIFIED_FILES
43+
44+
# - name: Run `codee format` on modified files
45+
# if: env.MODIFIED_FILES != ''
46+
# run: |
47+
# export PATH="${PWD}/codee-${CODEE_VERSION}-linux-x86_64/bin:${PATH}"
48+
# git codee-format --diff ${{ github.base_ref }} HEAD
49+
# git diff
50+
51+
# - name: Commit changes
52+
# if: env.MODIFIED_FILES != ''
53+
# run: |
54+
# if ! git diff --quiet; then
55+
# # Push with the github-actions user. More information at:
56+
# # https://github.com/actions/checkout?tab=readme-ov-file#push-a-commit-using-the-built-in-token
57+
# git commit -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" -am "Apply codee format formatting fixes"
58+
# git push --set-upstream origin ${{ github.head_ref }}
59+
# else
60+
# echo "No changes detected."
61+
# exit 0
62+
# fi

0 commit comments

Comments
 (0)