Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
163 commits
Select commit Hold shift + click to select a range
35f83ec
docs: development status of aitools in readme
marc-romu May 3, 2025
86704a4
Merge branch 'feature/scripting-tools' of https://github.com/architec…
marc-romu May 3, 2025
0802fe9
docs
marc-romu May 3, 2025
9f98fc2
ci
marc-romu May 3, 2025
ba6b675
UPDATE DEV FROM MAIN (#199)
marc-romu May 7, 2025
c221dd9
update feature/scripting-tools branch (#200)
marc-romu May 8, 2025
4804e7b
refactor(aitools): renamed gh_retrieve_components by gh_get_available…
marc-romu May 8, 2025
28e2a36
feat(ghget): avoid getting humanReadable filed if value is already hu…
marc-romu May 9, 2025
08c314e
feat(scripttools): added new script tools
marc-romu May 11, 2025
87866bb
chore(windsurf): update windsurf rules
marc-romu May 11, 2025
30776f0
chore(scripttools): reorder of using statements
marc-romu May 11, 2025
5a905df
feat(ghmove): enable undo movements triggered by gh_move_obj
marc-romu May 12, 2025
5cb4f54
feat(move): add undo feature to MoveInstance
marc-romu May 12, 2025
9b7c62f
feat(undo): undo support to SetComponentPreview and SetComponentLock
marc-romu May 12, 2025
2284011
Update src/SmartHopper.Core.Grasshopper/Tools/GhObjTools.cs
marc-romu May 12, 2025
16ee1da
feat(undo): undo support for move preview and lock setters (#201)
marc-romu May 12, 2025
4542657
docs: update version badge for dev
actions-user May 12, 2025
95d42cc
docs: update version badge for dev to 0.3.2-dev.250512 (#202)
marc-romu May 12, 2025
561874f
feat(ghput): compatibility with script components
marc-romu May 12, 2025
a7f4433
feat(ghgetput): compatibility with script inputs and outputs
marc-romu May 12, 2025
e4551f1
fix(ghput): fix duplication of input and output params in scripts
marc-romu May 12, 2025
dcc4ef0
feat(ghgetput): add support for parameter modifiers in inputs and out…
marc-romu May 12, 2025
116794b
fix: failing code style checks
marc-romu May 13, 2025
bd57cda
fix(ghget): obtain modifiers from script components and place them
marc-romu May 13, 2025
18e1f95
ci: split code-style analyses into independent jobs
marc-romu May 13, 2025
7b44ad7
ci: header check fix
marc-romu May 13, 2025
cb1fa70
ci: prevent fail before notifying all errors
marc-romu May 13, 2025
ea39731
refactor(ghput): migrated ghputtools to core.grasshopper.utils
marc-romu May 13, 2025
1597176
ci: debug in header-fixer
marc-romu May 13, 2025
21d8dba
ci: fix
marc-romu May 13, 2025
b7f3a83
feat(script_new): new script generation ai tool
marc-romu May 13, 2025
349bf9d
ci: simplified header-fixer logic
marc-romu May 13, 2025
8049c34
ci: added comprehensible errors in header-fixer
marc-romu May 13, 2025
2f4f4e9
ci: more logs in header-fixer
marc-romu May 13, 2025
38a4981
ci: header-fixer
marc-romu May 13, 2025
163d3e7
ci
marc-romu May 13, 2025
914cadf
ci: output line where mismatch was found
marc-romu May 13, 2025
2f353f6
ci: code-style commit changes on fix
marc-romu May 13, 2025
ad15d24
ci: fix commit issue for header-fixer
marc-romu May 13, 2025
c565eca
ci: fix commit issue
marc-romu May 13, 2025
07f6edd
ci: fix download-artifact version
marc-romu May 13, 2025
8cfab54
ci: use artifacts v4
marc-romu May 13, 2025
6424613
ci: do not use context in diffs
marc-romu May 13, 2025
457c1a8
chore(ci): apply code style fixes
github-actions[bot] May 13, 2025
61750df
Revert "chore(ci): apply code style fixes"
marc-romu May 13, 2025
a7ba391
ci: avoid supressing using statements
marc-romu May 13, 2025
afa7170
ci: close open comments
marc-romu May 13, 2025
7030fdd
ci: improved close comments
marc-romu May 13, 2025
7882726
ci: omit auto-generated files
marc-romu May 13, 2025
d9e56f1
Merge branch 'ci/tests' of https://github.com/architects-toolkit/Smar…
marc-romu May 13, 2025
6e06b69
ci: solve comments after adding header
marc-romu May 13, 2025
8f76bf0
ci: debug
marc-romu May 13, 2025
07c0bbd
ci: fix fail on counting comments
marc-romu May 13, 2025
776124c
chore(ci): apply code style fixes
github-actions[bot] May 13, 2025
301ae9d
Revert "chore(ci): apply code style fixes"
marc-romu May 13, 2025
6a5d7ea
feat(aiprovider): add compatibility with json output
marc-romu May 18, 2025
03bca24
docs(readme): added planned json components in readme
marc-romu May 18, 2025
c1f6cdf
docs(readme): added planned json components in readme
marc-romu May 18, 2025
342c0b1
feat(aitools): add inputs and outputs in script_new tool
marc-romu May 18, 2025
9cecc0a
fix(aiproviders): OpenAI error in API URI
marc-romu May 18, 2025
bf8dc13
Merge branch 'dev' into feature/scripting-tools
marc-romu May 18, 2025
690e4a4
feat(scripting): Add script component support and enhance AI tools (#…
marc-romu May 18, 2025
0bd6c77
fix: incoherent namespaces
marc-romu May 18, 2025
8fb2f36
ci: clean debug messages
marc-romu May 18, 2025
46baa02
ci: fix wiping out using statements
marc-romu May 18, 2025
5d963f0
ci
marc-romu May 18, 2025
1208e50
ci: process file per line instead of full text
marc-romu May 18, 2025
10b8d94
ci: enable fix for code-style fixer
marc-romu May 18, 2025
595683c
chore(ci): apply code style fixes
github-actions[bot] May 18, 2025
be797cb
fix: headers
marc-romu May 18, 2025
57ec501
ci: code-style github action (#204)
marc-romu May 18, 2025
0352840
ci: headers
marc-romu May 18, 2025
8a0c9b0
fix(scripttools): close editor after script_edit
marc-romu May 20, 2025
65ef0dc
fix(compilation)
marc-romu May 25, 2025
343fbef
fix(build): github release build
marc-romu May 25, 2025
bfb34e0
fix(put): removes all default inputs and outputs from the component b…
marc-romu May 25, 2025
bb7b304
feat(script_new): return the guid of the new added component
marc-romu May 25, 2025
b94576b
refactor(aitools): split texttools and listtools into smaller files p…
marc-romu May 25, 2025
774859f
refactor: text and list components to the new class names for changed…
marc-romu May 25, 2025
50c50e9
refactor: headers
marc-romu May 25, 2025
407445a
fix(script_new): incorrect instance guid
marc-romu May 25, 2025
ebad45a
refactor: removed script_edit
marc-romu May 25, 2025
640bc5c
refactor: minor bug fixes (#205)
marc-romu May 25, 2025
bf66ce8
docs: update version badge for dev
actions-user May 25, 2025
c4972ca
docs: update version badge for dev to 0.3.2-dev.250525 (#206)
marc-romu May 25, 2025
bce37b3
fix: removed failing tests due to missing pwsh dev for visual studio
marc-romu May 25, 2025
226b1dc
remove: test config file
marc-romu May 25, 2025
59f13c5
fix: pr-validation codestyle check
marc-romu May 25, 2025
1a2ec44
ci: tests (#207)
marc-romu May 25, 2025
0ad61e9
refactor: also ci tests on dev branch
marc-romu May 25, 2025
0fbd66f
refactor: migrates GhObjTools and GhPutTools into smaller files
marc-romu May 25, 2025
b745c98
docs
marc-romu May 25, 2025
875c5fd
remove: removed unnecessary eto.forms reference in config csproj
marc-romu May 25, 2025
54950c4
refactor: cleanup unnecessary code in list_filter
marc-romu May 25, 2025
877e0b9
refactor: webtools
marc-romu May 25, 2025
a7e8aa4
refactor(components): aitextgenerate aitextevaluate listevaluate and …
marc-romu May 25, 2025
262948b
fix(readme): make tests badge show results for the current branch
marc-romu May 26, 2025
7fdf8f2
Merge branch 'ci/tests' of https://github.com/architects-toolkit/Smar…
marc-romu May 26, 2025
622a191
fix: solve merge conflicts
marc-romu May 26, 2025
e839304
feat: limit ci test to pushed to main dev and release branches and pr…
marc-romu May 26, 2025
1443754
ci: new action to centralize build operations including signing and a…
marc-romu May 26, 2025
47c7ad5
ci: omit specific test badges per branch
marc-romu May 26, 2025
0dcb3fc
ci: change trigger
marc-romu May 26, 2025
e1581aa
Update .github/actions/dotnet-build/action.yml
marc-romu May 26, 2025
45710bd
ci: fix dotnet-build action to use inputs
marc-romu May 26, 2025
564e498
Merge branch 'ci/tests' of https://github.com/architects-toolkit/Smar…
marc-romu May 26, 2025
af9f949
ci: fix errors
marc-romu May 26, 2025
c461281
ci: repo misname
marc-romu May 26, 2025
500f4c9
ci: fix incorrect version variable in dotnet-build action
marc-romu May 26, 2025
750ccd0
ci: trailing-space check now returns line where error was found
marc-romu May 26, 2025
bb5f6d8
ci: split get-version action into windows and linux os
marc-romu May 26, 2025
aae8922
ci: trailing-spaces check only in non hidden folders
marc-romu May 26, 2025
dad71cb
ci: validate changelog requirement in pr only if there are changes in…
marc-romu May 26, 2025
92f0f7c
ci: fix dupicated ids
marc-romu May 26, 2025
1aa040c
ci: unify windows and ubuntu get-version steps
marc-romu May 26, 2025
ee3ac5f
ci: fix incorrect line reported in trailing-space check
marc-romu May 26, 2025
761a609
ci: update build process (#210)
marc-romu May 26, 2025
d814b34
refactor(aitools): migrated script tools into script_new and script_r…
marc-romu May 26, 2025
c12d90d
fix(aitool): fix text_generate text_evaluate list_filter and list_eva…
marc-romu May 26, 2025
e059fe8
fix(components): added missing provider and model parameters when cal…
marc-romu May 26, 2025
63874f6
feat(components): new callaitool in aistatefulasynccomponentbase to h…
marc-romu May 26, 2025
058c618
chore: update readme
marc-romu May 26, 2025
6073052
feat(aitool): aitool define their own endpoint thus removed from aist…
marc-romu May 26, 2025
11c891c
ci: fix failing authenticode and strongname tests
marc-romu May 28, 2025
d618b71
docs
marc-romu May 28, 2025
4e6bf4f
fix: using sorter action using wrong param in dotnet format
marc-romu May 28, 2025
7985006
ci: fix case when no project was provided
marc-romu May 28, 2025
e3617b6
fix: trailing whitespaces
marc-romu May 28, 2025
82d7973
fix: using directives failing because windows is required
marc-romu May 28, 2025
3a9f9cf
feat: visible errors and warnings in pr-validation
marc-romu May 28, 2025
7605a80
ci
marc-romu May 28, 2025
17ddf65
ci: code style fix
marc-romu May 28, 2025
10317ae
ci: remove crlf check
marc-romu May 28, 2025
87a8b20
fix: ci using sorter check getting many warnings for unrelated issues
marc-romu May 28, 2025
cc05c52
fix
marc-romu May 28, 2025
cd0fc69
fix: limit code-style using sorting fixer to relevant diagnostic ids
marc-romu May 28, 2025
116c8fd
ci: fix failing authenticode and strongname tests (#211)
marc-romu May 28, 2025
2f770ca
chore: update development version date to 0.3.2-dev.250528
actions-user May 28, 2025
90f3f28
chore: update development version date to 0.3.2-dev.250528 (#212)
marc-romu May 28, 2025
e8a87b8
Merge branch 'dev' into refactor/aitools
marc-romu May 28, 2025
97ba3d7
Update src/SmartHopper.Core.Grasshopper/Tools/script_new.cs
marc-romu May 28, 2025
07ad324
refactor(aitools): reorganization and centralize calling to ai tools …
marc-romu May 28, 2025
c00992d
feat: new yak upload release step
marc-romu May 28, 2025
0d6f1d6
docs
marc-romu May 28, 2025
4c7dd07
feat: update manifest description
marc-romu May 28, 2025
0588bde
ci: added confirmation check
marc-romu May 28, 2025
2778ed4
ci: use native yak build command
marc-romu May 28, 2025
1205c3d
ci: updated yak rules
marc-romu May 28, 2025
452f84d
ci: updated yak rules
marc-romu May 28, 2025
be43481
ci: minor fixes
marc-romu May 28, 2025
884b85f
feat(ci): add yak package upload workflow (#214)
marc-romu May 28, 2025
55674aa
refactor: smarthopper logo
marc-romu Jun 15, 2025
fd169f8
refactor: openai logo
marc-romu Jun 15, 2025
648a8c9
refactor: component icons
marc-romu Jun 15, 2025
7fa01b7
refactor: component descriptions
marc-romu Jun 15, 2025
f53b365
refactor: thanks logo design
marc-romu Jun 15, 2025
2316ddd
refactor: imports order
marc-romu Jun 15, 2025
a010f31
refactor(icons): updated icons and smarthopper logo (#215)
marc-romu Jun 15, 2025
ad70cbb
chore: update development version date to 0.3.2-dev.250615
actions-user Jun 15, 2025
9a1943a
chore: update development version date to 0.3.2-dev.250615 (#216)
marc-romu Jun 15, 2025
de77806
ci: fix trying to delete unexisting branch
marc-romu Jun 15, 2025
12e03f4
chore: prepare release 0.3.2-alpha with version update and code style…
actions-user Jun 15, 2025
69928f4
chore: prepare release 0.3.2-alpha with version update and code style…
marc-romu Jun 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# Auto detect text files and perform LF normalization
* text=auto

# Ensure consistent LF line endings for specific file types
*.md text eol=lf
*.ps1 text eol=lf
*.cs text eol=lf
7 changes: 5 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
# Critical repository files
/.gitignore @marc-romu
/.gitattributes @marc-romu
/.windsurfrules @marc-romu
/.windsurf/** @marc-romu
*.ps1 @marc-romu

# Critical solution files
/*.sln @marc-romu
/NuGet.Config @marc-romu
/Solution.props @marc-romu
/Directory.Build.props @marc-romu
/Directory.Build.targets @marc-romu
/Directory.Build.targets @marc-romu

# Yak package
/yak-package/** @marc-romu
41 changes: 26 additions & 15 deletions .github/actions/code-style/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,44 @@ runs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0.x'
- name: Run dotnet-format
shell: bash
run: |
dotnet restore
dotnet tool install -g dotnet-format || true
export PATH="$HOME/.dotnet/tools:$PATH"
if [ "${{ inputs.mode }}" = "check" ]; then
dotnet format --verify-no-changes
else
dotnet format
fi
- name: Process C# file headers
# - name: Run dotnet-format
# shell: bash
# run: |
# dotnet restore
# dotnet tool install -g dotnet-format || true
# export PATH="$HOME/.dotnet/tools:$PATH"
# if [ "${{ inputs.mode }}" = "check" ]; then
# dotnet format --verify-no-changes
# else
# dotnet format
# fi
- id: header
name: Process C# file headers
continue-on-error: ${{ inputs.mode == 'check' }}
uses: ./.github/actions/code-style/header-fixer
with:
mode: soft-check
- name: Process trailing whitespace
- id: whitespace
name: Process trailing whitespace
continue-on-error: ${{ inputs.mode == 'check' }}
uses: ./.github/actions/code-style/trailing-whitespace
with:
mode: ${{ inputs.mode }}
- name: Process using directives
- id: using_sorter
name: Process using directives
continue-on-error: ${{ inputs.mode == 'check' }}
uses: ./.github/actions/code-style/using-sorter
with:
mode: ${{ inputs.mode }}
- name: Check namespaces
- id: namespace_fixer
name: Check namespaces
continue-on-error: ${{ inputs.mode == 'check' }}
uses: ./.github/actions/code-style/namespace-fixer
with:
mode: soft-check
- name: Fail on check errors
if: ${{ inputs.mode == 'check' && (steps.header.outcome == 'failure' || steps.whitespace.outcome == 'failure' || steps.using_sorter.outcome == 'failure' || steps.namespace_fixer.outcome == 'failure') }}
run: exit 1
- name: Commit & push changes
if: ${{ inputs.commit }}
shell: bash
Expand Down
135 changes: 111 additions & 24 deletions .github/actions/code-style/header-fixer/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
mode:
description: "Operation mode: fix, check, or soft-check"
required: false
default: "soft-check"
default: "check"
runs:
using: "composite"
steps:
Expand All @@ -14,6 +14,15 @@ runs:
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_EVENT_PATH: ${{ github.event_path }}
run: |
# Set the shell to exit on error
set -o errexit -o pipefail

# Set up error handling
trap 'echo "HEADER-FIXER ERR: line $LINENO, cmd: $BASH_COMMAND" >&2' ERR

# Debug information
echo "Header Fixer Debug: mode=${{ inputs.mode }}, event=$GITHUB_EVENT_NAME"

# Determine files to process: changed in PR or all .cs in src/
if [ "$GITHUB_EVENT_NAME" = "pull_request" ] && [ -f "$GITHUB_EVENT_PATH" ]; then
BASE_SHA=$(jq -r .pull_request.base.sha < "$GITHUB_EVENT_PATH")
Expand All @@ -23,47 +32,125 @@ runs:
# Fallback to all .cs files under src/
FILES=$(find src -type f -name '*.cs')
fi

# Debug information
# echo "DEBUG: Determined files: $FILES"
# echo "Files to process: length=${#FILES[@]}"

# If no files, skip
if [ -z "$FILES" ]; then
echo "No C# files to process"
exit 0
fi
ERR=0
FAILED_FILES=()
for file in $FILES; do
# echo "DEBUG: Processing file: $file"
if [ -f "$file" ]; then
year=$(grep -m1 '^ \* Copyright' "$file" | grep -oE '[0-9]{4}')
# Skip auto-generated files
if head -n 20 "$file" | grep -q '<auto-generated>'; then
echo "Skipping auto-generated file $file"
continue
fi

# Get year
year=$(grep -m1 '^ \* Copyright' "$file" | grep -oE '[0-9]{4}' || true)
# echo "DEBUG: Extracted year=$year for $file"
[ -z "$year" ] && year=$(date +%Y)

# Create header template
HEADER="/*\n * SmartHopper - AI-powered Grasshopper Plugin\n * Copyright (C) $year Marc Roca Musach\n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public\n * License as published by the Free Software Foundation; either\n * version 3 of the License, or (at your option) any later version.\n */"

# Get current header
HEADER_LINES=$(echo -e "$HEADER" | wc -l)
CURRENT_HEADER=$(head -n $HEADER_LINES "$file")
# Header template lines
HEADER_LINES_ARRAY=(
"/*"
" * SmartHopper - AI-powered Grasshopper Plugin"
" * Copyright (C) $year Marc Roca Musach"
" *"
" * This library is free software; you can redistribute it and/or"
" * modify it under the terms of the GNU Lesser General Public"
" * License as published by the Free Software Foundation; either"
" * version 3 of the License, or (at your option) any later version."
" */"
""
)
HEADER_LINE_COUNT=${#HEADER_LINES_ARRAY[@]}

# Compare header per-line ignoring year
# echo "Comparing header for $file"
mismatch=0
mismatch_line=0
for ((i=0; i<HEADER_LINE_COUNT; i++)); do
TEMPLATE_LINE=${HEADER_LINES_ARRAY[i]}
FILE_LINE=$(sed -n "$((i+1))p" "$file")
TEMPLATE_CAN=$(echo "$TEMPLATE_LINE" | sed -E 's/(Copyright \(C\) )[0-9]{4}/\1####/')
CURRENT_CAN=$(echo "$FILE_LINE" | sed -E 's/(Copyright \(C\) )[0-9]{4}/\1####/')
if [[ "$TEMPLATE_CAN" != "$CURRENT_CAN" ]]; then
mismatch=1
mismatch_line=$((i+1))
break
fi
done

if [ "$HEADER" != "$CURRENT_HEADER" ]; then
# echo "Header mismatch flag for $file: $mismatch"
# Process header mismatch
if (( mismatch == 1 )); then
if [ "${{ inputs.mode }}" = "fix" ]; then
echo "Updating header in $file"
# Find namespace line
NAMESPACE_LINE=$(grep -n '^namespace ' "$file" | head -1 | cut -d: -f1)
if [ -n "$NAMESPACE_LINE" ]; then
# Extract content from namespace line to end
CONTENT=$(tail -n +$NAMESPACE_LINE "$file")
# Write new file with correct header
echo -e "$HEADER\n\n$CONTENT" > "$file"
echo "DEBUG: mismatch_line=$mismatch_line, HEADER_LINE_COUNT=$HEADER_LINE_COUNT"

# Read file into array for selective updates
readarray -t FILE_CONTENT < "$file"
# Determine if full header insertion or line update
if [ "$mismatch_line" -eq 1 ]; then
echo "DEBUG: Full header missing, inserting full header"
NEW_HEADER=$(printf "%s\n" "${HEADER_LINES_ARRAY[@]}")
printf "%s\n\n" "$NEW_HEADER" > "$file"
printf "%s\n" "${FILE_CONTENT[@]}" >> "$file"
else
echo "Warning: Could not find namespace line in $file"
TEMPLATE_LINE="${HEADER_LINES_ARRAY[$((mismatch_line-1))]}"
echo "DEBUG: Replacing header line $mismatch_line with: $TEMPLATE_LINE"
FILE_CONTENT[$((mismatch_line-1))]="$TEMPLATE_LINE"
printf "%s\n" "${FILE_CONTENT[@]}" > "$file"
fi
else
if [ "${{ inputs.mode }}" = "soft-check" ]; then
# emit a non-blocking warning
echo "::warning file=$file::Header mismatch in $file (run with mode=fix to auto-fix)"
else
echo "Header mismatch in $file"
ERR=1

# Check and fix unbalanced comment blocks in first 20 lines
HEAD_LINES=$(head -n 20 "$file")
OPEN_COUNT=$(grep -o '/\*' <<<"$HEAD_LINES" | wc -l || true)
CLOSE_COUNT=$(grep -o '\*/' <<<"$HEAD_LINES" | wc -l || true)
echo "DEBUG: OPEN_COUNT=$OPEN_COUNT, CLOSE_COUNT=$CLOSE_COUNT in first 20 lines"
if [ "$OPEN_COUNT" -ne "$CLOSE_COUNT" ]; then
echo "DEBUG: Unbalanced comments in header area, fixing"
if [ "$OPEN_COUNT" -lt "$CLOSE_COUNT" ]; then
# Add missing /* before first comment line
awk 'NR <= 20 && /^[[:space:]]*\*/ && !x {print "/*"; x=1}1' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
else
# Add missing */ after last comment line
awk 'NR <= 20 && /\*\// && !x {print; print "*/"; x=1; next}1' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi
fi

elif [ "${{ inputs.mode }}" = "soft-check" ]; then
# emit a non-blocking warning
echo "::warning file=$file::Header mismatch in $file (run with mode=fix to auto-fix)"

elif [ "${{ inputs.mode }}" = "check" ]; then
# Emit error annotation and collect failure
echo "::error file=$file,line=$mismatch_line::Header mismatch in $file"
FAILED_FILES+=("$file:$mismatch_line")
ERR=1
fi
fi
fi
done

# Summarize failures in check mode
if [ "${{ inputs.mode }}" = "check" ] && [ ${#FAILED_FILES[@]} -ne 0 ]; then
echo " Header validation failed for the following files (file:line):"
for entry in "${FAILED_FILES[@]}"; do
path=${entry%%:*}
ln=${entry##*:}
echo " - $path (line $ln)"
done
echo "Run with mode=fix to automatically update headers"
elif [ "${{ inputs.mode }}" = "check" ]; then
echo " All header validations passed"
fi
exit $ERR
6 changes: 5 additions & 1 deletion .github/actions/code-style/namespace-fixer/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ runs:
if: always()
shell: bash
run: |
# Set the shell to continue on error
set +e

# Get the list of changed files
if [ -n "${{ github.event.pull_request }}" ]; then
FILES=$(git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" -- '*.cs')
else
Expand All @@ -38,7 +42,7 @@ runs:
# emit a non-blocking warning
echo "::warning file=$file::Namespace mismatch in $file (run with mode=fix to auto-fix)"
else
echo "Namespace mismatch in $file: expected $ns but found $actual"
echo "::error file=$file::Namespace mismatch in $file: expected $ns but found $actual"
ERR=1
fi
fi
Expand Down
35 changes: 28 additions & 7 deletions .github/actions/code-style/trailing-whitespace/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,45 @@ runs:
- name: Process trailing whitespace
shell: bash
run: |
FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
# Set the shell to continue on error
set +e

# Get the list of changed files
FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -v -e '^\.' -e '/\.')

# Initialize error code
ERR=0

# Process each file
for file in $FILES; do
if [[ -f "$file" ]]; then
if [[ "${{ inputs.mode }}" == "fix" ]]; then
sed -i 's/[ \t]*$//' "$file"
# normalize to unix line endings
sed -i 's/\r$//' "$file"
else
if grep -qE '[ \t]+$' "$file" || file "$file" | grep -q CRLF; then
if [ "${{ inputs.mode }}" = "soft-check" ]; then
# emit a non-blocking warning
echo "::warning file=$file::Trailing whitespace or CRLF found in $file (run with mode=fix to auto-fix)"
# Report trailing whitespace
while IFS= read -r entry; do
path="${entry%%:*}"
num="${entry#*:}"
if [[ "${{ inputs.mode }}" == "soft-check" ]]; then
echo "::warning file=$path,line=$num::Trailing whitespace found"
else
echo "Trailing whitespace or CRLF found in $file"
echo "::error file=$path,line=$num::Trailing whitespace found"
ERR=1
fi
fi
done < <(grep -nE '[[:blank:]]$' "$file" || true)
# # Report CRLF
# while IFS= read -r entry; do
# path="${entry%%:*}"
# num="${entry#*:}"
# if [[ "${{ inputs.mode }}" == "soft-check" ]]; then
# echo "::warning file=$path,line=$num::CRLF found in $file:$num"
# else
# echo "::error file=$path,line=$num::CRLF found in $file:$num"
# ERR=1
# fi
# done < <(grep -n $'\\r$' "$file" || true)
fi
fi
done
Expand Down
44 changes: 37 additions & 7 deletions .github/actions/code-style/using-sorter/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,46 @@ runs:
run: |
FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- '*.cs')
ERR=0
dotnet tool install -g dotnet-format || true
export PATH="$HOME/.dotnet/tools:$PATH"

# Function to find the nearest project or solution file
find_project_file() {
local dir="$(dirname "$1")"
local project_file

while [ "$dir" != "/" ] && [ "$dir" != "." ]; do
project_file=$(find "$dir" -maxdepth 1 -type f \( -name '*.csproj' -o -name '*.sln' \) | head -n 1)
if [ -n "$project_file" ]; then
echo "$project_file"
return 0
fi
dir="$(dirname "$dir")"
done
return 1
}

# Process each file
for file in $FILES; do
if [ -f "$file" ]; then
if [ "${{ inputs.mode }}" = "check" ] || [ "${{ inputs.mode }}" = "soft-check" ]; then
dotnet format "$file" --verify-no-changes --fix-analyzers
if [[ -f "$file" ]]; then
project_file=$(find_project_file "$file")
if [ $? -ne 0 ]; then
echo "::warning file=$file::Could not find project or solution file for $file"
continue
fi

if [[ "${{ inputs.mode }}" == "fix" ]]; then
dotnet format style --diagnostics IDE0005 SA1208 SA1210 --include "$file" "$project_file"
else
dotnet format "$file" --fix-analyzers
dotnet format style --diagnostics IDE0005 SA1208 SA1210 --include "$file" "$project_file" --verify-no-changes
CODE=$?
if [ $CODE -ne 0 ]; then
if [ "${{ inputs.mode }}" = "soft-check" ]; then
echo "::warning file=$file::Using sorter found issues in $file (run with mode=fix to auto-fix)"
else
echo "Using sorter check failed in $file"
ERR=1
fi
fi
fi
fi
done
# fail if any check error
exit $ERR
Loading
Loading