-
Notifications
You must be signed in to change notification settings - Fork 67
Check (but not fix) Fortran format in GitHub actions #717
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1891310
Add comment to src/ccpp_hash_table.F90 so that file is 'modified'
climbfuji 4854c83
Update existing GitHub action workflows: concurrency, only run for PR…
climbfuji da63617
Turn off all tests except Codee formatting
climbfuji adea079
Add .github/workflows/fortran-formatting.yaml
climbfuji 34c643b
Merge adea079b28793f7c13a7c657a99ee1fe2f315a89 into 6999e2e5d8f914be3…
climbfuji 9a23af4
Apply codee format formatting fixes
github-actions[bot] 62486ee
Rogue reformatting of src/ccpp_hash_table.F90
climbfuji 6214664
Re-enable other GitHub workflows
climbfuji c609436
Apply suggestion from @climbfuji
climbfuji 643c094
Merge branch 'develop' into feature/codee_ci
climbfuji c24b104
Apply suggestion from @climbfuji
climbfuji File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 ... | ||
climbfuji marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #- 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 }} | ||
climbfuji marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| !!XXgoldyXX: To do, statistics output | ||
| module ccpp_hash_table | ||
|
|
||
| ! Modify this file ... | ||
|
||
|
|
||
climbfuji marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| use ccpp_hashable, only: ccpp_hashable_t | ||
|
|
||
| implicit none | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.