-
Notifications
You must be signed in to change notification settings - Fork 65
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
Open
climbfuji
wants to merge
8
commits into
NCAR:develop
Choose a base branch
from
climbfuji:feature/codee_ci
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 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 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 ... | ||
| #- 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 }} |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 4-5 will be removed before merging the PR, this will allow the newly added test to pass.