Skip to content

[SNOW-921048] Add Linter as mandatory github action #123

[SNOW-921048] Add Linter as mandatory github action

[SNOW-921048] Add Linter as mandatory github action #123

Workflow file for this run

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
- 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: Fetch all history for all branches and tags
run: git fetch --prune --unshallow
- name: Determine changed files
id: changed-files
run: |
PR_NUMBER=$(echo "${{ github.event.number }}" | tr -d '\n')
PR_FILES=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/files" | jq -r '.[].filename')
echo "CHANGED_FILES=$PR_FILES" >> $GITHUB_ENV
- name: Run dotnet format on changed files
run: |
for file in $CHANGED_FILES; do
if [[ $file == *.cs ]]; then
echo "Formatting $file"
dotnet format $file --include $file --verify-no-changes --no-restore
fi
done