Skip to content

F/gh action tab check - #3469

Open
andrew-platt wants to merge 2 commits into
OpenFAST:rc-5.0.1from
andrew-platt:f/GH_action_tab_check
Open

andrew-platt wants to merge 2 commits into
OpenFAST:rc-5.0.1from
andrew-platt:f/GH_action_tab_check

Conversation

@andrew-platt

Copy link
Copy Markdown
Collaborator

PR: Add GitHub action to check Fortran source for tab characters

Base branch: rc-5.0.1
Head branch: f/GH_action_tab_check
Commits: 316018d32, bf06cde90
Diffstat: 8 files changed, 116 insertions(+), 9 deletions(-)


Feature or improvement description

Adds a CI check that enforces the OpenFAST Fortran source style rule that tab
characters are not allowed. OpenFAST style requires 3 space indentation; tabs
render inconsistently across editors and break the alignment of continuation
lines, so they should never reach the repository.

Two files are added:

  • .github/workflows/check-tabs.yml -- a Fortran Source Style workflow that
    runs on pushes touching **.f90 / **.F90 (or the check's own files) and on
    every pull request. It checks out with submodules: false, so the r-test
    submodule is never scanned.
  • .github/scripts/check_tabs.sh -- the check itself. It enumerates source
    files with git ls-files -- '*.f90' '*.F90', so out-of-tree build
    directories and untracked scratch files are excluded by construction. Every
    tab found is reported with its file, line number, and column, and the
    offending line is echoed with tabs rendered as --->. The job exits non-zero
    if any tab is found.

Sample output:

OpenFAST Fortran source style check
===================================

OpenFAST style requires 3 space indentation in all Fortran source files.
Tab characters are not allowed.

modules/moordyn/src/MoorDyn_Line.f90
   line 1781, column 1: --->   ! endif

Checked 267 Fortran source file(s).

ERROR: found 1 line(s) containing tab characters in 1 file(s).
       Replace each tab with spaces (3 space indentation) and commit the fix.
       Tabs above are shown as '--->'.

Each hit is additionally emitted as a GitHub ::error file=...,line=...,col=...::
annotation, so findings appear inline on the pull request diff rather than only
in the job log.

This pull request also removes the tab characters that were already present in
the source tree -- 20 tabs spanning 8 lines across 5 files -- so the check
passes on a clean tree.

Related issue, if one exists

None.

Impacted areas of the software

Continuous integration only. No compiled behavior changes.

File Change
.github/workflows/check-tabs.yml New workflow
.github/scripts/check_tabs.sh New check script
modules/lindyn/src/LinDyn.f90 3 tabs removed from a comment block (lines 727-729)
modules/moordyn/src/MoorDyn_Line.f90 1 leading tab removed from a commented-out line (1781)
modules/nwtc-library/Old_test/.../Test_MeshMapping_Mod.f90 2 whitespace-only lines emptied (1260, 1278)
modules/nwtc-library/src/NWTC_Num.f90 1 tab removed from a Doxygen comment (1080)
modules/servodyn/src/StrucCtrl_Registry.txt Tabs removed from the omega_P description string
modules/servodyn/src/StrucCtrl_Types.f90 Regenerated from the above

Every source edit is confined to comments or whitespace-only lines. No
executable statement, declaration, interface, or registry type definition was
modified, so no module behavior changes and no regression test output should
move.

Additional supporting information

Design decisions worth noting for review:

  • Registry-generated files. *_Types.f90 files are excluded from the scan,
    since they are produced by the OpenFAST Registry rather than edited by hand.
    A tab in one of them indicates a problem in the corresponding registry input,
    not in code a developer can fix in place.

  • The ServoDyn fix demonstrates exactly that case. StrucCtrl_Types.f90 held
    four tabs inside the Doxygen comment for omega_P. The Registry had copied
    them verbatim from the quoted description string at
    StrucCtrl_Registry.txt:141. The fix was made in the registry input, aligning
    the string with the neighboring alpha_P entry, and StrucCtrl_Types.f90 was
    regenerated. The regeneration produced exactly the one expected line change
    and no other churn, confirming the committed generated file was in sync with
    its input beforehand.

  • Registry .txt files are out of scope by design. They are tab-delimited as
    a matter of format, so they are correctly not scanned. Only tabs that leak
    into a quoted description string reach generated Fortran, and those are caught
    indirectly through review rather than by this check.

  • The _Types.f90 exclusion is currently not load-bearing. After this pull
    request, no tracked .f90 / .F90 file in the tree contains a tab, generated
    files included. The exclusion is retained as a guard: without it, a stray tab
    in any registry description string would fail CI on a file no developer can
    hand-edit. Reviewers who would rather check everything can simply drop the
    grep -v '_Types\.f90$' filter in check_tabs.sh.

Generative AI usage

Substantial portions of this work were AI-assisted.

  • Claude Code (Anthropic Claude Opus 5) authored the workflow, the check script,
    and the four comment/whitespace cleanups in LinDyn.f90,
    MoorDyn_Line.f90, Test_MeshMapping_Mod.f90, and NWTC_Num.f90, and traced
    the StrucCtrl_Types.f90 tab back to its registry source.
  • GitHub Copilot assisted with the StrucCtrl_Registry.txt description-string
    edit.
  • The Registry regeneration of StrucCtrl_Types.f90 was run by the author.

Trailers present on the branch commits:

316018d32  Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
bf06cde90  Assisted-by: LLM [Claude Code] [Copilot]

Test results, if applicable
None suggested.

andrew-platt and others added 2 commits September 18, 2026 13:53
OpenFAST style requires 3 space indentation in Fortran source; tab
characters are not allowed because they render inconsistently across
editors and break continuation-line alignment.

Add a workflow that scans every git-tracked *.f90 / *.F90 file and
reports the file, line, and column of each tab found, failing the job
if any are present. Findings are also emitted as GitHub annotations so
they appear inline on the pull request diff.

Registry-generated *_Types.f90 files are excluded from the scan, since
they are produced by the OpenFAST Registry rather than edited by hand.

Also remove the 7 pre-existing tab characters so the check passes on a
clean tree. All were in comments or whitespace-only lines, so there is
no change in behavior.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The omega_P description in StrucCtrl_Registry.txt contained tab
characters, which the Registry copied verbatim into the generated
Doxygen comment in StrucCtrl_Types.f90. Replace them with spaces,
matching the alignment of the neighboring alpha_P entry, and
regenerate StrucCtrl_Types.f90.

Comment text only; no change in behavior.

Assisted-by: LLM [Claude Code] [Copilot]
@andrew-platt andrew-platt added this to the v5.0.1 milestone Sep 18, 2026
@andrew-platt
andrew-platt requested review from luwang00 and a lite review from Copilot September 18, 2026 20:13
@andrew-platt andrew-platt self-assigned this Sep 18, 2026
@andrew-platt andrew-platt added the System: GH actions GitHub actions related workflows/scripting label Sep 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new CI check script currently has error-handling gaps that can mask failures (e.g., ineffective git-root guard and treating grep errors as “no matches”), which could allow tabs to slip through undetected.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR adds a GitHub Actions workflow and companion script to enforce the OpenFAST Fortran style rule that git-tracked .f90/.F90 sources must not contain tab characters, and cleans up existing tabs so the new check passes.

Changes:

  • Add a new GitHub Actions workflow to run the tab check on relevant pushes and on all pull requests.
  • Add a bash script that enumerates tracked Fortran sources, reports tab locations (with GitHub ::error annotations), and fails CI if any are found.
  • Remove existing tab characters / tab-only whitespace from several Fortran sources and update the ServoDyn registry description string and regenerated _Types.f90 output accordingly.
File summaries
File Description
.github/workflows/check-tabs.yml Adds CI workflow wiring to run the repository tab scan on PRs and relevant pushes.
.github/scripts/check_tabs.sh Implements the tab detection and GitHub annotation reporting logic.
modules/lindyn/src/LinDyn.f90 Removes tabs from comment block lines so the new check passes.
modules/moordyn/src/MoorDyn_Line.f90 Removes a leading tab from a commented-out line.
modules/nwtc-library/Old_test/Test_MeshMapping/Test_MeshMapping_Mod.f90 Replaces tab-only/whitespace-only lines with empty lines.
modules/nwtc-library/src/NWTC_Num.f90 Removes a tab from a Doxygen/math comment line.
modules/servodyn/src/StrucCtrl_Registry.txt Replaces tabs inside a quoted description string to prevent tabs from propagating into generated Fortran.
modules/servodyn/src/StrucCtrl_Types.f90 Updates the regenerated comment spacing for omega_P to remove tabs.
Review details
  • Files reviewed: 2/8 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

n_bad_lines=0

for file in "${FILES[@]}"; do
matches=$(grep -n -- "$TAB" "$file") || continue
TAB=$(printf '\t')
MARK='--->'

cd "$(git rev-parse --show-toplevel)" || exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

System: GH actions GitHub actions related workflows/scripting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants