Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
6 changes: 5 additions & 1 deletion .github/workflows/capgen_unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ name: Capgen Unit Tests
on:
workflow_dispatch:
pull_request:
branches: [develop, main]
branches: [develop]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
unit_tests:
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/fortran-formatting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Codee format Fortran

on:
pull_request:
branches: [develop]
types: [opened, synchronize, labeled, unlabeled]

env:
CODEE_VERSION: 2025.4.5

# Only needed when fixing formatting automatically, but this only
# works for pull requests from the same repo, not from a fork
#permissions:
# contents: write
# pull-requests: write

jobs:
format:
name: Check and fix Fortran formatting
runs-on: ubuntu-22.04

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get modified Fortran files
run: |
git remote -v show
git fetch origin ${{ github.base_ref }}
MODIFIED_FILES=$(git diff --name-only --diff-filter=d origin/${{ github.base_ref }}...HEAD -- '*.f90' '*.F90' '*.f' '*.F')
echo "MODIFIED_FILES=${MODIFIED_FILES}" >> ${GITHUB_ENV}

- name: Install Codee
if: env.MODIFIED_FILES != ''
run: |
echo "Installing Codee ${CODEE_VERSION} ..."
wget https://codee.com/release/codee-${CODEE_VERSION}-linux-x86_64.tar.gz
tar -xf codee-${CODEE_VERSION}-linux-x86_64.tar.gz

- name: Run `codee format` on modified files
if: env.MODIFIED_FILES != ''
run: |
export PATH="${PWD}/codee-${CODEE_VERSION}-linux-x86_64/bin:${PATH}"
codee format --accept-eula --verbose ${MODIFIED_FILES}
REFORMATTED_FILES=$(git diff --name-only --diff-filter=d)
echo "REFORMATTED_FILES=${REFORMATTED_FILES}" >> ${GITHUB_ENV}

- name: Fail if there are uncommitted changes
if: ${{ env.REFORMATTED_FILES != '' }}
run: |
echo "Formatting issues detected. Run 'codee format' locally or apply the following diff manually:"
git diff
exit 1

#- name: Fail if there are uncommitted changes and the `fix-fortran-format` label is not present
# if: ${{ env.REFORMATTED_FILES != '' && !contains(github.event.pull_request.labels.*.name, 'fix-fortran-format') }}
# run: |
# echo "Formatting issues detected. Run 'codee format' locally or attach label 'fix-fortran-format' to this PR."
# exit 1
#
# This doesn't work if the pull request comes from a fork ...
#- name: Commit changes if the `fix-fortran-format` label is not present
# if: ${{ env.REFORMATTED_FILES != '' && contains(github.event.pull_request.labels.*.name, 'fix-fortran-format') }}
# run: |
# # Push with the github-actions user. More information at:
# # https://github.com/actions/checkout?tab=readme-ov-file#push-a-commit-using-the-built-in-token
# git config user.name "github-actions[bot]"
# git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# git checkout -b ${{ github.head_ref }}
# git add ${REFORMATTED_FILES}
# git commit -m "Apply codee format formatting fixes"
#
# git remote add realsource ${{ github.event.pull_request.head.repo.clone_url }}
# git remote -v show
# git push --set-upstream source ${{ github.head_ref }}
# # If PR comes from the target repository (origin), can do:
# # git push --set-upstream origin ${{ github.head_ref }}
1 change: 1 addition & 0 deletions .github/workflows/prebuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: ccpp-prebuild

on:
pull_request:
branches: [develop]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ name: Python package
on:
workflow_dispatch:
pull_request:
branches: [develop, main]
branches: [develop]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
Expand Down