[SNOW-921048] Add Linter as mandatory github action #125
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Dependencies update check | |
id: dependencies | |
run: | | |
current_commit=`git log -n 1 --pretty=format:%H` | |
echo $current_commit | |
last_deps_mod_commit=`git log -n 1 --pretty=format:%H -- composer.json` | |
echo $last_deps_mod_commit | |
if [ $current_commit == $last_deps_mod_commit ]; then echo USE_LOCK=0 > ci.conf; else echo USE_LOCK=1 > ci.conf; fi | |
- name: List all changed files | |
env: | |
ALL_CHANGED_FILES: ${{ steps.dependencies.outputs.current_commit }} | |
run: | | |
for file in ${ALL_CHANGED_FILES}; do | |
echo "$file was changed" | |
done | |
- name: Run dotnet format on changed files | |
run: | | |
for file in $ALL_CHANGED_FILES; do | |
if [[ $file == *.cs ]]; then | |
echo "Formatting $file" | |
dotnet format $file --include $file --verify-no-changes --no-restore | |
fi | |
done |