Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add .net lint action #49

Merged
merged 5 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions .github/actions/dotnet/lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: .NET lint

# Note: this action requires .NET 6+ SDK

inputs:
WORKING_DIRECTORY:
required: true
type: string
SHELL:
required: false
type: string
default: 'bash'

runs:
using: composite
steps:
- name: .NET lint style
shell: ${{ inputs.SHELL }}
run: dotnet format style --verify-no-changes
working-directory: ${{ inputs.WORKING_DIRECTORY }}

- name: .NET lint analyzers
shell: ${{ inputs.SHELL }}
run: dotnet format analyzers --verify-no-changes
working-directory: ${{ inputs.WORKING_DIRECTORY }}
5 changes: 5 additions & 0 deletions .github/workflows/dotnet-workflow-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ jobs:
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
BUILD_CONFIG: "Debug"

- name: Lint
uses: zupit-it/pipeline-templates/.github/actions/dotnet/[email protected]
with:
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}

- name: Run tests
uses: zupit-it/pipeline-templates/.github/actions/dotnet/[email protected]
with:
Expand Down
47 changes: 42 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ If you would like to get more details of these tasks, just look at this [doc](do
1. [Install](#net-action---install)
2. [Build](#net-action---build)
3. [Format](#net-action---format)
4. [Test](#net-action---test)
5. [Publish](#net-action---publish)
6. [Release](#net-action---release)
4. [Lint](#net-action---lint)
5. [Test](#net-action---test)
6. [Publish](#net-action---publish)
7. [Release](#net-action---release)
5. [Azure](#azure-action)
1. [App Service](#azure-action---app-service---deploy)
2. [Storage Account](#azure-action---storage-account---deploy)
Expand Down Expand Up @@ -327,6 +328,41 @@ steps:
CSHARPIER_VERSION: "0.25.0"
```

#### .NET Action - Lint

This action:
- run the `dotnet format` command on the `WORKING_DIRECTORY`.

###### Requirements

- The `WORKING_DIRECTORY` directory must contain a solution or a project file.
- The correct .NET (6+) version must be installed.

_This workflow doesn't download the codebase. You have to check out the repo by yourself._

###### Action

**.github/actions/dotnet/lint** is the action that lints the code of a .NET solution.

It requires these inputs:

- **WORKING_DIRECTORY**: The directory where the runner can execute all the commands. It must contain a solution (`.sln`) or a project (`.csproj`) file.

In addition, it is possible to specify this optional input:

- **SHELL**: The shell type to use. By default, it is **bash**.

This is an example to show how data should be formatted.

```yaml
steps:
- name: Build
uses: zupit-it/pipeline-templates/.github/actions/dotnet/[email protected]
with:
WORKING_DIRECTORY: "backend"
SHELL: "bash"
```

#### .NET Action - Test

This action:
Expand Down Expand Up @@ -1308,13 +1344,14 @@ This workflow is based on the following actions:
- [.NET - Install](#net-action---install)
- [.NET - Build](#net-action---build)
- [.NET - Format](#net-action---format)
- [.NET - Lint](#net-action---lint)
- [.NET - Test](#net-action---test)

Check these actions requirements before using this workflow.

###### Workflow

**dotnet-workflow-common.yml** is the reusable workflow to check that the code is correctly linted and that all tests pass.
**dotnet-workflow-common.yml** is the reusable workflow to check that the code is correctly linted, formatted, and that all tests pass.

It requires these inputs:

Expand All @@ -1329,7 +1366,7 @@ jobs:
common:
uses: zupit-it/pipeline-templates/.github/workflows/[email protected]
with:
WORKING_DIRECTORY: "back-end"
WORKING_DIRECTORY: "backend"
DOTNET_IMAGE: "'mcr.microsoft.com/dotnet/sdk:7.0"
CONTAINER_CI_LABELS: "['team', 'pipeline', 'container']"
```
Expand Down