-
Notifications
You must be signed in to change notification settings - Fork 8
Fortran linting workflow #28
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
James Bruten (james-bruten-mo)
merged 23 commits into
MetOffice:main
from
Pierre-siddall:fortitude-linting
Nov 17, 2025
Merged
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
5fa991c
add README
Pierre-siddall af70fd2
Implement fortitude linter with pip
Pierre-siddall e7cb482
README skeleton and python version number bump
Pierre-siddall 3b833e6
add configuration explaination
Pierre-siddall 26cbbb8
Explain usage in caller workflow
Pierre-siddall f1e0007
Fix YAML linting
Pierre-siddall 1c97253
Update to stable fortitude version number
Pierre-siddall 855cd5c
Update fortran-lint/README.md
Pierre-siddall cd6c221
Update fortran-lint/README.md
Pierre-siddall 0d53ee5
Update fortran-lint/README.md
Pierre-siddall 785241d
Update fortran-lint/README.md
Pierre-siddall c825321
Update fortran-lint/README.md
Pierre-siddall 8b68f8f
optimise workflow using uv
Pierre-siddall 7ed29b5
fix trailing whitespace
Pierre-siddall 9332a29
Setup uv step
Pierre-siddall b731473
Fix uv setup and caching
Pierre-siddall 485565c
Apply initial fixes raised by sci/tech
Pierre-siddall 630304d
specify target file formats
Pierre-siddall 12654fc
add link to fortitude documentation in README
Pierre-siddall c3e242f
Condense title
Pierre-siddall 11870ea
Update .github/workflows/fortran-lint.yaml
Pierre-siddall 1f3317c
add input types
Pierre-siddall d41ebb5
Update .github/workflows/fortran-lint.yaml
Pierre-siddall 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # ------------------------------------------------------------------------------ | ||
| # (c) Crown copyright Met Office. All rights reserved. | ||
| # The file LICENCE, distributed with this code, contains details of the terms | ||
| # under which the code may be used. | ||
| # ------------------------------------------------------------------------------ | ||
|
|
||
| name: Fortran lint | ||
| on: | ||
| workflow_call: | ||
|
|
||
| inputs: | ||
| runner: | ||
| description: 'The runner to use for the job' | ||
| required: false | ||
| default: 'ubuntu-latest' | ||
| timeout: | ||
| description: 'The maximum time in minutes the job can run for' | ||
| required: false | ||
| default: 10 | ||
| python-version: | ||
| description: 'The Python version to use' | ||
| required: false | ||
| default: '3.14' | ||
|
|
||
| concurrency: | ||
| group: ${{ github.ref}} | ||
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
|
||
| jobs: | ||
| fortitude-linting: | ||
| name: Fortran lint | ||
| runs-on: ${{ inputs.runner }} | ||
| timeout-minutes: ${{ inputs.timeout }} | ||
|
|
||
| env: | ||
| UV_CACHE_DIR: /tmp/.uv_cache | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Setup uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| python-version: ${{ inputs.python-version }} | ||
| enable-cache: true | ||
|
|
||
| - name: restore uv cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ env.UV_CACHE_DIR }} | ||
| key: ${{ runner.os }}-${{ hashFiles('uv.lock') }}-fortitude-0.7.3 | ||
| restore-keys: | | ||
| uv-${{ runner.os }}-${{ hashFiles('uv.lock') }} | ||
| uv-${{ runner.os }} | ||
|
|
||
| - name: Install Fortitude Linter | ||
| run: | | ||
| uv pip install fortitude-lint==0.7.3 | ||
|
Pierre-siddall marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: Run Fortitude Linter | ||
| run: fortitude check --respect-gitignore --show-fixes --file-extensions=f90,F90,x90,X90 . | ||
|
|
||
| - name: minimize uv cache | ||
| run: uv cache prune --ci | ||
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,46 @@ | ||
| # Fortran Linting workflow (using Fortitude) | ||
|
|
||
| This reusable workflow serves as a a generic workflow to lint fortran | ||
| code using the fortitude linter. | ||
|
|
||
| ## Usage | ||
|
|
||
| By default this workflow will check all the rules included in fortitude linter. | ||
| However, should you wish to check only a certain set of rules in your local repository | ||
| you can do this by implementing a `fortitude.toml` file in the top-level/root directory | ||
| of your local repository, defining the rules which should be checked when running this | ||
| reusable workflow from a caller workflow. The following toml file is an example of | ||
| what your `fortitude.toml` file could look like: | ||
|
|
||
| ### Example fortitude configuration | ||
|
Pierre-siddall marked this conversation as resolved.
|
||
|
|
||
| ```toml | ||
| [check] | ||
| select = ["S", "T"] | ||
| ignore = ["S001", "S051"] | ||
| line-length = 132 | ||
| ``` | ||
|
|
||
| In order to use this reusable workflow you should implement a calling workflow as | ||
|
Pierre-siddall marked this conversation as resolved.
|
||
| a YAML file in your `.github/workflows` directory containing the follwing: | ||
|
|
||
| ### Example usage in caller workflow | ||
|
Pierre-siddall marked this conversation as resolved.
|
||
|
|
||
| ```yaml | ||
| steps: | ||
| - name: Lint Fortran | ||
| uses: MetOffice/growss/.github/workflows/fortan-lint.yaml@main | ||
|
|
||
| with: | ||
| runner: The runner to use for the job (ubuntu-latest) | ||
| timeout: The maximum time in minutes the job can run for (10) | ||
| python-version: The Python version to use (3.14) | ||
| ``` | ||
|
|
||
| Where runner,timeout and python-version are all appropriately defined inputs | ||
| to the workflow as defined in `MetOffice/growss/.github/workflows/fortan-lint.yaml` | ||
|
|
||
| ### Further details | ||
| Fortitude is a fortran linter developed and maintained by PlasmaFAIR. For further details on | ||
| how to configure your `fortitude.toml` file and how to interpret error messages given by this | ||
| reusable workflow please refer to the [fortitude doumentation](https://fortitude.readthedocs.io/en/latest/) | ||
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.