Skip to content

Commit fc5abe1

Browse files
bart-vmwareTimHess
andauthored
Add GHA workflow for Code Style (#1530)
* Add GHA workflow for Code Style * Add line break * Update .github/workflows/verify-code-style.yml Co-authored-by: Tim Hess <[email protected]> --------- Co-authored-by: Tim Hess <[email protected]>
1 parent 9ab0d04 commit fc5abe1

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Verify code style
2+
3+
on:
4+
push:
5+
branches: [ 'main', 'release/*' ]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
15+
16+
env:
17+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
18+
DOTNET_NOLOGO: true
19+
20+
jobs:
21+
verify-code-style:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Setup .NET
25+
uses: actions/setup-dotnet@v4
26+
with:
27+
dotnet-version: |
28+
8.0.*
29+
9.0.*
30+
31+
- name: Checkout repo
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Restore tools
37+
run: dotnet tool restore --verbosity minimal
38+
39+
- name: Restore packages
40+
run: dotnet restore src --verbosity minimal
41+
42+
- name: Set package version
43+
run: nbgv cloud
44+
45+
- name: CleanupCode (on PR diff)
46+
if: github.event_name == 'pull_request'
47+
shell: pwsh
48+
run: |
49+
# Not using the environment variables for SHAs, because they may be outdated. This may happen on force-push after the build is queued, but before it starts.
50+
# The below works because HEAD is detached (at the merge commit), so HEAD~1 is at the base branch. When a PR contains no commits, this job will not run.
51+
$headCommitHash = git rev-parse HEAD
52+
$baseCommitHash = git rev-parse HEAD~1
53+
54+
Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request."
55+
dotnet regitlint -s src/Steeltoe.All.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --properties:NuGetAudit=false --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff
56+
57+
- name: CleanupCode (on branch)
58+
if: github.event_name == 'push' || github.event_name == 'release'
59+
shell: pwsh
60+
run: |
61+
Write-Output "Running code cleanup on all files."
62+
dotnet regitlint -s src/Steeltoe.All.sln --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --properties:NuGetAudit=false --jb --verbosity=WARN --fail-on-diff --print-diff

0 commit comments

Comments
 (0)