diff --git a/.github/workflows/capgen_unit_tests.yaml b/.github/workflows/capgen_unit_tests.yaml index 374681f1..4b8598f0 100644 --- a/.github/workflows/capgen_unit_tests.yaml +++ b/.github/workflows/capgen_unit_tests.yaml @@ -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: diff --git a/.github/workflows/fortran-formatting.yaml b/.github/workflows/fortran-formatting.yaml new file mode 100644 index 00000000..bb0b568b --- /dev/null +++ b/.github/workflows/fortran-formatting.yaml @@ -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 }} diff --git a/.github/workflows/prebuild.yaml b/.github/workflows/prebuild.yaml index 43eda35c..6ef3841c 100644 --- a/.github/workflows/prebuild.yaml +++ b/.github/workflows/prebuild.yaml @@ -2,6 +2,7 @@ name: ccpp-prebuild on: pull_request: + branches: [develop] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index fc12a3d1..b8508f2a 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -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: diff --git a/src/ccpp_hash_table.F90 b/src/ccpp_hash_table.F90 index 685c9049..af268450 100644 --- a/src/ccpp_hash_table.F90 +++ b/src/ccpp_hash_table.F90 @@ -1,6 +1,8 @@ !!XXgoldyXX: To do, statistics output module ccpp_hash_table +! Modify this file ... + use ccpp_hashable, only: ccpp_hashable_t implicit none