diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..02fb909a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +name: CI + +on: + push: + branches: [ "main" ] + +jobs: + build: + name: CI + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up .Net Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0 + + - name: dotnet test + run: dotnet test --configuration Release + + - name: dotnet publish + run: dotnet publish src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj --configuration Release -o artifcats + + - name: upload artifactes + uses: actions/upload-artifact@v4 + with: + name: lab-artifact + path: artifcats/ \ No newline at end of file diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml new file mode 100644 index 00000000..5e185f76 --- /dev/null +++ b/.github/workflows/cron.yml @@ -0,0 +1,17 @@ +name: Run every minute + # set this to the .NET Core version to use +on: + schedule: + - cron: "*/5 * * * *" + + +jobs: + cron: + name: Run every 5 minutes + runs-on: ubuntu-latest + + steps: + - name: Greetings + run: echo "Hello World" + + \ No newline at end of file diff --git a/.github/workflows/pr-verify.yml b/.github/workflows/pr-verify.yml new file mode 100644 index 00000000..6056dc0b --- /dev/null +++ b/.github/workflows/pr-verify.yml @@ -0,0 +1,32 @@ +name: PR Verify + +env: + AZURE_WEBAPP_NAME: your-app-name # set this to the name of your Azure Web App + AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root + DOTNET_VERSION: '5' # set this to the .NET Core version to use + +on: + pull_request: + branches: [ "main" ] + +jobs: + build: + name: PR Verify + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0 + + - name: Build with dotnet + run: dotnet build --configuration Release + + - name: DotNet Test + run: dotnet test --configuration Release --no-build + + - name: DotNet Fromatting + run: dotnet format -v detailed --verify-no-changes \ No newline at end of file diff --git a/global.json b/global.json index 2ddda36c..93681ff8 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.0", + "version": "9.0.0", "rollForward": "latestMinor", "allowPrerelease": false } diff --git a/src/GitHubActionsDotNet.Api.Tests/GitHubActionsDotNet.Api.Tests.csproj b/src/GitHubActionsDotNet.Api.Tests/GitHubActionsDotNet.Api.Tests.csproj index 424bab8f..e8a7bed8 100644 --- a/src/GitHubActionsDotNet.Api.Tests/GitHubActionsDotNet.Api.Tests.csproj +++ b/src/GitHubActionsDotNet.Api.Tests/GitHubActionsDotNet.Api.Tests.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable diff --git a/src/GitHubActionsDotNet.Api/Controllers/WeatherForecastController.cs b/src/GitHubActionsDotNet.Api/Controllers/WeatherForecastController.cs index d91d7957..f017a55a 100644 --- a/src/GitHubActionsDotNet.Api/Controllers/WeatherForecastController.cs +++ b/src/GitHubActionsDotNet.Api/Controllers/WeatherForecastController.cs @@ -21,11 +21,10 @@ public class WeatherForecastController : ControllerBase ]; [HttpGet(Name = "GetWeatherForecast")] - public IEnumerable Get() => Enumerable.Range(1, 5).Select(index => new WeatherForecast + public IEnumerable Get() => [.. Enumerable.Range(1, 5).Select(index => new WeatherForecast { Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), TemperatureC = Random.Shared.Next(-20, 55), Summary = Summaries[Random.Shared.Next(Summaries.Length)] - }) - .ToArray(); + })]; } diff --git a/src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj b/src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj index f18b2634..7bcce63a 100644 --- a/src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj +++ b/src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable true