diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index d8f4f19..4edab68 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -4,6 +4,10 @@ on: branches: [ "main" ] pull_request: branches: [ "main" ] +permissions: + contents: read + actions: read + checks: write jobs: Testing: runs-on: ubuntu-latest @@ -30,11 +34,27 @@ jobs: - name: Run integration tests if: success() || failure() run: dotnet test --no-build --verbosity normal --logger 'junit' --results-directory './.test-results/integration' ./tests/Integration/Integration.csproj; - - name: Publish artifacts + - name: Create Code Style Report + if: success() || failure() + uses: x-coders-team/dotnet-format-results@beta + id: code-style-html-report + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + json-results: '[]' + runner-workdir: ${{ github.workspace }} + - name: Publish artifacts generated by tests uses: actions/upload-artifact@v3 if: success() || failure() with: name: test-results path: | .test-results/unit/TestResults.xml - .test-results/integration/TestResults.xml \ No newline at end of file + .test-results/integration/TestResults.xml + - name: Publish artifacts generated by code style checks + uses: actions/upload-artifact@v3 + if: success() || failure() + with: + name: code-style-checks-results + path: | + .linter-results/dotnet/ diff --git a/src/CrontabRegistry/Application/Controllers/WeatherForecastController.cs b/src/CrontabRegistry/Application/Controllers/WeatherForecastController.cs index 0b41a79..17df2b8 100644 --- a/src/CrontabRegistry/Application/Controllers/WeatherForecastController.cs +++ b/src/CrontabRegistry/Application/Controllers/WeatherForecastController.cs @@ -6,9 +6,8 @@ namespace CrontabRegistry.Application.Controllers { [ApiController] [Route("[controller]")] - public class WeatherForecastController : ControllerBase - { - private readonly ILogger _logger; + public class WeatherForecastController : ControllerBase{ + private readonly ILogger _logger ; private readonly IWeatherForecastService _weatherForecastService; public WeatherForecastController( @@ -17,13 +16,11 @@ IWeatherForecastService weatherForecastService ) { _logger = logger; - _weatherForecastService = weatherForecastService; - } - + _weatherForecastService = weatherForecastService;} [HttpGet(Name = "GetWeatherForecast")] - public async Task> Get() - { + public async Task >Get (){ return await _weatherForecastService.GenerateWeatherForecast(); } } -} \ No newline at end of file +} + diff --git a/src/CrontabRegistry/Application/Services/WeatherForecastService.cs b/src/CrontabRegistry/Application/Services/WeatherForecastService.cs index 30b4358..e0bbcdd 100644 --- a/src/CrontabRegistry/Application/Services/WeatherForecastService.cs +++ b/src/CrontabRegistry/Application/Services/WeatherForecastService.cs @@ -1,9 +1,9 @@ using CrontabRegistry.Domain.Models; -using CrontabRegistry.Domain.Repositories; -using CrontabRegistry.Domain.Services; +using CrontabRegistry.Domain.Services;using CrontabRegistry.Domain.Repositories; -namespace CrontabRegistry.Application.Services -{ + + +namespace CrontabRegistry.Application.Services{ public class WeatherForecastService : IWeatherForecastService { private readonly IWeatherForecastRepository _weatherForecastRepository; @@ -15,16 +15,17 @@ IWeatherForecastRepository weatherForecastRepository _weatherForecastRepository = weatherForecastRepository; } - public async Task> GenerateWeatherForecast() - { + public async Task> GenerateWeatherForecast(){ var summaries = await _weatherForecastRepository.GetSummaries(); - return Enumerable.Range(1, 5).Select(index => new WeatherForecastModel - { + return Enumerable.Range(1, 5).Select(index => new WeatherForecastModel { Date = DateTime.Now.AddDays(index), TemperatureC = Random.Shared.Next(-20, 55), Summary = summaries[Random.Shared.Next(summaries.Length)] - }).ToArray(); - } + }).ToArray();} } + + + + }