From ea3f7056959fbec9c14a62734d16aeb31f281d5d Mon Sep 17 00:00:00 2001 From: cuqmbr Date: Wed, 30 Apr 2025 00:36:57 +0300 Subject: [PATCH] add ci/cd actions workflow --- .github/workflows/ci-cd.yml | 120 ++++++++++++++++++ src/Application/packages.lock.json | 9 +- src/Configuration/packages.lock.json | 46 +++++++ src/Identity/packages.lock.json | 41 ++++++ src/Infrastructure/packages.lock.json | 9 +- src/Persistence/packages.lock.json | 13 ++ .../Application.IntegrationTests.csproj | 4 + .../packages.lock.json | 51 ++++++++ 8 files changed, 291 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci-cd.yml diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 0000000..56207bd --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -0,0 +1,120 @@ +--- + +on: push + +runs-on: ubuntu-latest + +env: + test_artifacts_name: test_artifacts + application_artifacts_name: application_artifacts + +jobs: + build: + env: + build_artifacts_path: ${{github.workspace}}/build + test_artifacts_path: ${{env.build_artifacts_path}}/tests + application_artifacts_path: ${{env.build_artifacts_path}}/application + NUGET_PACKAGES: ${{github.workspace}}/.nuget/packages + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup dotnet environment + uses: actions/setup-dotnet@v4 + with: + global-json-file: global.json + cache: true + cache-dependency-path: | + src/Application/packages.lock.json + src/Identity/packages.lock.json + src/Infrastructure/packages.lock.json + src/Persistence/packages.lock.json + src/Configuration/packages.lock.json + src/HttpApi/packages.lock.json + tst/Application.IntegrationTests/packages.lock.json + - name: Download package dependencies + run: dotnet restore . + - name: Build Application.IntegrationTests + run: > + dotnet publish ./tst/Application.IntegrationTests + --output ${test_artifacts_path} --configuration Release + --self-contained --use-current-runtime + -p:PublishSingleFile=true -p:PublishSingleFile=true + - name: Clean test artifacts directory + run: > + find ${test_artifacts_path} -type f -print0 | + perl -0ne 'print if /.*(pdb|dll|txt|json|targets|props)/s' | + xargs -r0 rm -Rf; + find ${test_artifacts_path} -mindepth 1 -type d -print0 | + xargs -r0 rm -Rf + - name: Upload test artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{env.test_artifacts_name}} + path: ${{env.test_artifacts_path}} + - name: Build HttpApi project + run: > + dotnet publish ./src/HttpApi --output ${application_artifacts_path} + --configuration Release -p:PublishSingleFile=true + --self-contained --use-current-runtime + -p:PublishSingleFile=true -p:PublishSingleFile=true + - name: Clean application artifacts directory + run: > + find ${application_artifacts_path} -type f -print0 | + perl -0ne 'print if /.*(\.pdb|\.dll|\.so)/s' | + xargs -r0 rm -Rf; + find ${application_artifacts_path} -mindepth 1 -type d -print0 | + xargs -r0 rm -Rf + - name: Upload application artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{env.application_artifacts_name}} + path: ${{env.application_artifacts_path}} + + tests: + needs: build + env: + artifacts_path: ./artifacts + steps: + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: ${{env.test_artifacts_name}} + path: ${{env.artifacts_path}} + - name: Make Application.IntegrationTests executalbe + run: chmod u+x ${artifacts_path}/Application.IntegrationTests + - name: Run Application.IntegrationTests + run: ${artifacts_path}/Application.IntegrationTests + + build-docker: + needs: tests + env: + registry: gitea.cuqmbr.xyz + steps: + - name: Login to Docker Container Registry + uses: docker/login-action@v3 + with: + registry: ${{env.registry}} + username: ${{vars.DOCKER_USER}} + password: ${{secrets.DOCKER_TOKEN}} + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: true + # TODO: split tag names into multiple lines + tags: | + ${{env.registry}}/${{github.repository_owner}}/${{github.event.repository.name}}/${{github.ref_name}}:${{github.sha}} + ${{env.registry}}/${{github.repository_owner}}/${{github.event.repository.name}}/${{github.ref_name}}:latest + # + # deploy: + # needs: build-docker + # steps: + # - name: Checkout infrastructure repository + # - name: Run ansible deployment playbook + # # Use ${{github.sha}} when specifying image to deploy diff --git a/src/Application/packages.lock.json b/src/Application/packages.lock.json index f56b518..0718004 100644 --- a/src/Application/packages.lock.json +++ b/src/Application/packages.lock.json @@ -59,6 +59,12 @@ "Microsoft.Extensions.Options": "9.0.4" } }, + "Microsoft.NET.ILLink.Tasks": { + "type": "Direct", + "requested": "[9.0.3, )", + "resolved": "9.0.3", + "contentHash": "1rqGTfubVg0qj2PsK6esyq3PIxtYJYrN3LsYUV9RrvH3anmt3fT3ozYdAZZH4U8JU/pt5pPIUk8NBSu26wtekA==" + }, "System.Linq.Dynamic.Core": { "type": "Direct", "requested": "[1.6.2, )", @@ -173,6 +179,7 @@ "domain": { "type": "Project" } - } + }, + "net9.0/linux-x64": {} } } \ No newline at end of file diff --git a/src/Configuration/packages.lock.json b/src/Configuration/packages.lock.json index 7bd3fb8..e591490 100644 --- a/src/Configuration/packages.lock.json +++ b/src/Configuration/packages.lock.json @@ -150,6 +150,12 @@ "Microsoft.Extensions.Primitives": "9.0.4" } }, + "Microsoft.NET.ILLink.Tasks": { + "type": "Direct", + "requested": "[9.0.3, )", + "resolved": "9.0.3", + "contentHash": "1rqGTfubVg0qj2PsK6esyq3PIxtYJYrN3LsYUV9RrvH3anmt3fT3ozYdAZZH4U8JU/pt5pPIUk8NBSu26wtekA==" + }, "System.Text.Json": { "type": "Direct", "requested": "[9.0.4, )", @@ -846,6 +852,46 @@ "Npgsql.EntityFrameworkCore.PostgreSQL": "[9.0.4, )" } } + }, + "net9.0/linux-x64": { + "Microsoft.Win32.Registry": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "+FWlwd//+Tt56316p00hVePBCouXyEzT86Jb3+AuRotTND0IYn0OO3obs1gnQEs/txEnt+rF2JBGLItTG+Be6A==", + "dependencies": { + "System.Security.AccessControl": "4.5.0", + "System.Security.Principal.Windows": "4.5.0" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.10", + "contentHash": "mAr69tDbnf3QJpRy2nJz8Qdpebdil00fvycyByR58Cn9eARvR+UiG2Vzsp+4q1tV3ikwiYIjlXCQFc12GfebbA==" + }, + "System.Security.AccessControl": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "vW8Eoq0TMyz5vAG/6ce483x/CP83fgm4SJe5P8Tb1tZaobcvPrbMEL7rhH1DRdrYbbb6F0vq3OlzmK0Pkwks5A==", + "dependencies": { + "Microsoft.NETCore.Platforms": "2.0.0", + "System.Security.Principal.Windows": "4.5.0" + } + }, + "System.Security.Cryptography.Pkcs": { + "type": "Transitive", + "resolved": "8.0.1", + "contentHash": "CoCRHFym33aUSf/NtWSVSZa99dkd0Hm7OCZUxORBjRB16LNhIEOf8THPqzIYlvKM0nNDAPTRBa1FxEECrgaxxA==" + }, + "System.Security.Principal.Windows": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "t0MGLukB5WAVU9bO3MGzvlGnyJPgUlcwerXn1kzBRjwLKixT96XV0Uza41W49gVd8zEMFu9vQEFlv0IOrytICA==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ==" + } } } } \ No newline at end of file diff --git a/src/Identity/packages.lock.json b/src/Identity/packages.lock.json index aa4f436..71a67ab 100644 --- a/src/Identity/packages.lock.json +++ b/src/Identity/packages.lock.json @@ -62,6 +62,12 @@ "Microsoft.IdentityModel.Logging": "8.8.0" } }, + "Microsoft.NET.ILLink.Tasks": { + "type": "Direct", + "requested": "[9.0.3, )", + "resolved": "9.0.3", + "contentHash": "1rqGTfubVg0qj2PsK6esyq3PIxtYJYrN3LsYUV9RrvH3anmt3fT3ozYdAZZH4U8JU/pt5pPIUk8NBSu26wtekA==" + }, "Npgsql.EntityFrameworkCore.PostgreSQL": { "type": "Direct", "requested": "[9.0.4, )", @@ -595,6 +601,41 @@ "domain": { "type": "Project" } + }, + "net9.0/linux-x64": { + "Microsoft.Win32.Registry": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "+FWlwd//+Tt56316p00hVePBCouXyEzT86Jb3+AuRotTND0IYn0OO3obs1gnQEs/txEnt+rF2JBGLItTG+Be6A==", + "dependencies": { + "System.Security.AccessControl": "4.5.0", + "System.Security.Principal.Windows": "4.5.0" + } + }, + "System.Security.AccessControl": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "vW8Eoq0TMyz5vAG/6ce483x/CP83fgm4SJe5P8Tb1tZaobcvPrbMEL7rhH1DRdrYbbb6F0vq3OlzmK0Pkwks5A==", + "dependencies": { + "Microsoft.NETCore.Platforms": "2.0.0", + "System.Security.Principal.Windows": "4.5.0" + } + }, + "System.Security.Cryptography.Pkcs": { + "type": "Transitive", + "resolved": "8.0.1", + "contentHash": "CoCRHFym33aUSf/NtWSVSZa99dkd0Hm7OCZUxORBjRB16LNhIEOf8THPqzIYlvKM0nNDAPTRBa1FxEECrgaxxA==" + }, + "System.Security.Principal.Windows": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "t0MGLukB5WAVU9bO3MGzvlGnyJPgUlcwerXn1kzBRjwLKixT96XV0Uza41W49gVd8zEMFu9vQEFlv0IOrytICA==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ==" + } } } } \ No newline at end of file diff --git a/src/Infrastructure/packages.lock.json b/src/Infrastructure/packages.lock.json index 83c6755..3fc0122 100644 --- a/src/Infrastructure/packages.lock.json +++ b/src/Infrastructure/packages.lock.json @@ -2,6 +2,12 @@ "version": 1, "dependencies": { "net9.0": { + "Microsoft.NET.ILLink.Tasks": { + "type": "Direct", + "requested": "[9.0.3, )", + "resolved": "9.0.3", + "contentHash": "1rqGTfubVg0qj2PsK6esyq3PIxtYJYrN3LsYUV9RrvH3anmt3fT3ozYdAZZH4U8JU/pt5pPIUk8NBSu26wtekA==" + }, "AspNetCore.Localizer.Json": { "type": "Transitive", "resolved": "1.0.1", @@ -179,6 +185,7 @@ "domain": { "type": "Project" } - } + }, + "net9.0/linux-x64": {} } } \ No newline at end of file diff --git a/src/Persistence/packages.lock.json b/src/Persistence/packages.lock.json index af85452..f9da6c3 100644 --- a/src/Persistence/packages.lock.json +++ b/src/Persistence/packages.lock.json @@ -51,6 +51,12 @@ "Microsoft.Extensions.Primitives": "9.0.4" } }, + "Microsoft.NET.ILLink.Tasks": { + "type": "Direct", + "requested": "[9.0.3, )", + "resolved": "9.0.3", + "contentHash": "1rqGTfubVg0qj2PsK6esyq3PIxtYJYrN3LsYUV9RrvH3anmt3fT3ozYdAZZH4U8JU/pt5pPIUk8NBSu26wtekA==" + }, "Npgsql.EntityFrameworkCore.PostgreSQL": { "type": "Direct", "requested": "[9.0.4, )", @@ -335,6 +341,13 @@ "domain": { "type": "Project" } + }, + "net9.0/linux-x64": { + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.10", + "contentHash": "mAr69tDbnf3QJpRy2nJz8Qdpebdil00fvycyByR58Cn9eARvR+UiG2Vzsp+4q1tV3ikwiYIjlXCQFc12GfebbA==" + } } } } \ No newline at end of file diff --git a/tst/Application.IntegrationTests/Application.IntegrationTests.csproj b/tst/Application.IntegrationTests/Application.IntegrationTests.csproj index 5351f98..5f846e4 100644 --- a/tst/Application.IntegrationTests/Application.IntegrationTests.csproj +++ b/tst/Application.IntegrationTests/Application.IntegrationTests.csproj @@ -36,4 +36,8 @@ true + + true + + diff --git a/tst/Application.IntegrationTests/packages.lock.json b/tst/Application.IntegrationTests/packages.lock.json index 017ffbc..aac2a27 100644 --- a/tst/Application.IntegrationTests/packages.lock.json +++ b/tst/Application.IntegrationTests/packages.lock.json @@ -11,6 +11,12 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.4" } }, + "Microsoft.NET.ILLink.Tasks": { + "type": "Direct", + "requested": "[9.0.3, )", + "resolved": "9.0.3", + "contentHash": "1rqGTfubVg0qj2PsK6esyq3PIxtYJYrN3LsYUV9RrvH3anmt3fT3ozYdAZZH4U8JU/pt5pPIUk8NBSu26wtekA==" + }, "Microsoft.NET.Test.Sdk": { "type": "Direct", "requested": "[17.13.0, )", @@ -1019,6 +1025,51 @@ "Npgsql.EntityFrameworkCore.PostgreSQL": "[9.0.4, )" } } + }, + "net9.0/linux-x64": { + "Microsoft.Win32.Registry": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "+FWlwd//+Tt56316p00hVePBCouXyEzT86Jb3+AuRotTND0IYn0OO3obs1gnQEs/txEnt+rF2JBGLItTG+Be6A==", + "dependencies": { + "System.Security.AccessControl": "4.5.0", + "System.Security.Principal.Windows": "4.5.0" + } + }, + "SQLitePCLRaw.lib.e_sqlite3": { + "type": "Transitive", + "resolved": "2.1.10", + "contentHash": "mAr69tDbnf3QJpRy2nJz8Qdpebdil00fvycyByR58Cn9eARvR+UiG2Vzsp+4q1tV3ikwiYIjlXCQFc12GfebbA==" + }, + "System.Diagnostics.EventLog": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "lcyUiXTsETK2ALsZrX+nWuHSIQeazhqPphLfaRxzdGaG93+0kELqpgEHtwWOlQe7+jSFnKwaCAgL4kjeZCQJnw==" + }, + "System.Security.AccessControl": { + "type": "Transitive", + "resolved": "4.5.0", + "contentHash": "vW8Eoq0TMyz5vAG/6ce483x/CP83fgm4SJe5P8Tb1tZaobcvPrbMEL7rhH1DRdrYbbb6F0vq3OlzmK0Pkwks5A==", + "dependencies": { + "Microsoft.NETCore.Platforms": "2.0.0", + "System.Security.Principal.Windows": "4.5.0" + } + }, + "System.Security.Cryptography.Pkcs": { + "type": "Transitive", + "resolved": "8.0.1", + "contentHash": "CoCRHFym33aUSf/NtWSVSZa99dkd0Hm7OCZUxORBjRB16LNhIEOf8THPqzIYlvKM0nNDAPTRBa1FxEECrgaxxA==" + }, + "System.Security.Principal.Windows": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "t0MGLukB5WAVU9bO3MGzvlGnyJPgUlcwerXn1kzBRjwLKixT96XV0Uza41W49gVd8zEMFu9vQEFlv0IOrytICA==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ==" + } } } } \ No newline at end of file