-
Notifications
You must be signed in to change notification settings - Fork 140
77 lines (66 loc) · 2.12 KB
/
linter.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Code standards check
# Triggers the workflow on pull request events but only for the master branch
on:
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
logLevel:
default: warning
description: "Log level"
required: true
tags:
description: "Linter"
required: false
permissions: { }
concurrency:
# older builds for the same pull request number or branch should be cancelled
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
run-linter:
name: Run linter
runs-on: windows-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
with:
depth: 0
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.103'
- name: Install dotnet format
run: dotnet tool install -g dotnet-format
- name: Add dotnet tools to PATH
run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
- name: Run dotnet restore
run: dotnet restore
- name: base SHA
id: base-sha
run: |
echo "baseSHA=git merge-base origin/master" >> $GITHUB_OUTPUT
- name: Get all changed files
id: changed-files
env:
BASE_SHA: ${{ steps.base-sha.outputs.baseSHA }}
run: |
echo "changed_files=git diff --name-only $BASE_SHA $GITHUB_SHA" >> $GITHUB_OUTPUT
- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.changed_files }}
run: |
echo "$ALL_CHANGED_FILES"
- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.changed_files }}
run: |
for (file in ${ALL_CHANGED_FILES}){
echo "$file was changed"
}
- name: Run dotnet format on changed files
run: |
for file in $ALL_CHANGED_FILES; do
echo "Formatting $file"
dotnet format $file --include $file --verify-no-changes --no-restore
done