From 42b881d403aaff20569f8602b322ec13dab2e8e1 Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Sat, 26 Aug 2023 23:14:31 +0200 Subject: [PATCH 01/12] Change build-test action Add deploy action --- .github/workflows/build-test.yml | 23 +-------- .github/workflows/deploy.yml | 80 ++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index def67e5..0cc262b 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -1,14 +1,12 @@ name: Build & Test on: - push: - branches: [ "master" ] pull_request: branches: [ "master" ] jobs: build: - if: github.event_name == 'pull_request' && github.event.pull_request.draft == false + if: github.event.pull_request.draft == false runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -24,25 +22,6 @@ jobs: run: dotnet build --no-restore - name: Test run: dotnet test --no-build --verbosity normal - build-upload-debug-files: - if: github.event_name == 'push' && github.event.push.ref == 'refs/heads/master' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 7.x.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --no-restore -c Release -p:SentryOrg=sentry -p:SentryProject=ss14-map-server -p:SentryUploadSymbols=true -p:SentryUploadSources=true -p:SentryUrl=https://bugs.tanukij.dev - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - - name: Test - run: dotnet test --no-build --verbosity normal ci-success: name: Build & Test Debug needs: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..25ed7d8 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,80 @@ +name: Build & Test + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + deploy-sentry: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.x.x + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --no-restore -c Release -p:SentryOrg=sentry -p:SentryProject=ss14-map-server -p:SentryUploadSymbols=true -p:SentryUploadSources=true -p:SentryUrl=https://bugs.tanukij.dev + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + + deploy-container: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + + - name: Docker Login + uses: docker/login-action@v2.2.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: get-net-sdk-project-versions-action + uses: kzrnm/get-net-sdk-project-versions-action@v1.3.0 + id: get-version + with: + proj-path: SS14.MapServer/SS14.MapServer.csproj + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.6.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest + type=raw,value=${{steps.get-version.outputs.version}} + + - name: Build and push Docker image + uses: docker/build-push-action@v4.1.1 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + ci-success: + name: Build & Test Debug + needs: + - deploy-sentry + - deploy-container + runs-on: ubuntu-latest + steps: + - name: CI succeeded + run: exit 0 From 4d92effe3144606056152af60cc275a40f8fb02d Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Sat, 26 Aug 2023 23:15:04 +0200 Subject: [PATCH 02/12] Fix deploy action --- .github/workflows/deploy.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 25ed7d8..a7cae85 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,8 +3,6 @@ on: push: branches: [ "master" ] - pull_request: - branches: [ "master" ] env: REGISTRY: ghcr.io From 3c3f88cabdb2ea767ec3fb99aa60e606518424bc Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Sat, 26 Aug 2023 23:17:39 +0200 Subject: [PATCH 03/12] Fix deploy action version extraction location --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a7cae85..894e263 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -48,7 +48,7 @@ jobs: uses: kzrnm/get-net-sdk-project-versions-action@v1.3.0 id: get-version with: - proj-path: SS14.MapServer/SS14.MapServer.csproj + proj-path: SS14.MapServer/SS14.MapServer/SS14.MapServer.csproj - name: Extract metadata (tags, labels) for Docker id: meta From 0d7a1d3bd45036e3ca4fa8fe8870d915cf35bde0 Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Sat, 26 Aug 2023 23:18:54 +0200 Subject: [PATCH 04/12] Fix not checking out project for delopy container job --- .github/workflows/deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 894e263..12fb46a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -44,6 +44,8 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v3 + - name: get-net-sdk-project-versions-action uses: kzrnm/get-net-sdk-project-versions-action@v1.3.0 id: get-version From 8d732fa8f971239549168e02d80addae10899ae9 Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Sat, 26 Aug 2023 23:19:55 +0200 Subject: [PATCH 05/12] Revert changing the version extraction location --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 12fb46a..b12643b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -50,7 +50,7 @@ jobs: uses: kzrnm/get-net-sdk-project-versions-action@v1.3.0 id: get-version with: - proj-path: SS14.MapServer/SS14.MapServer/SS14.MapServer.csproj + proj-path: SS14.MapServer/SS14.MapServer.csproj - name: Extract metadata (tags, labels) for Docker id: meta From 3fdf54eff3d92c2f3a77c7fe81253fdbd4412d1a Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Sat, 26 Aug 2023 23:22:20 +0200 Subject: [PATCH 06/12] Fix deploy container job not checking out submodules --- .github/workflows/deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b12643b..f16e717 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -45,6 +45,8 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v3 + with: + submodules: recursive - name: get-net-sdk-project-versions-action uses: kzrnm/get-net-sdk-project-versions-action@v1.3.0 From 7e535f19e0957fce6f40e0004d9b41504026328e Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Sat, 26 Aug 2023 23:27:13 +0200 Subject: [PATCH 07/12] [no ci] Change ci finished job name --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f16e717..dcb46b9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -72,7 +72,7 @@ jobs: labels: ${{ steps.meta.outputs.labels }} ci-success: - name: Build & Test Debug + name: Deploy finished needs: - deploy-sentry - deploy-container From 738dfe60a0e7c853cbc61f1bf9a12bc191e80e4e Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Sun, 27 Aug 2023 13:56:43 +0200 Subject: [PATCH 08/12] Restrict deleting junk files to not recurse through directories --- SS14.MapServer/Services/FileManagementService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SS14.MapServer/Services/FileManagementService.cs b/SS14.MapServer/Services/FileManagementService.cs index aeb07e5..5276e84 100644 --- a/SS14.MapServer/Services/FileManagementService.cs +++ b/SS14.MapServer/Services/FileManagementService.cs @@ -51,7 +51,7 @@ private Task InternalCleanBuildDirectories() foreach (var directory in poolDirectory.GetDirectories()) { var files = _processingConfiguration.JunkFilePatterns - .SelectMany(pattern => directory.EnumerateFiles(pattern, SearchOption.AllDirectories)); + .SelectMany(pattern => directory.EnumerateFiles(pattern, SearchOption.TopDirectoryOnly)); foreach (var file in files) { From 79c58a44b20b08d5ddaf357896422ef788782f0b Mon Sep 17 00:00:00 2001 From: Julian Giebel Date: Fri, 8 Sep 2023 11:15:56 +0200 Subject: [PATCH 09/12] Fix fetching submodules ignoring update rule set to none (#2) Bump version to 1.1.1 --- SS14.MapServer/SS14.MapServer.csproj | 2 +- SS14.MapServer/Services/GitService.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/SS14.MapServer/SS14.MapServer.csproj b/SS14.MapServer/SS14.MapServer.csproj index 9abc246..e271f11 100644 --- a/SS14.MapServer/SS14.MapServer.csproj +++ b/SS14.MapServer/SS14.MapServer.csproj @@ -5,7 +5,7 @@ enable enable Linux - 1.1 + 1.1.1 diff --git a/SS14.MapServer/Services/GitService.cs b/SS14.MapServer/Services/GitService.cs index 0537dc5..c16d099 100644 --- a/SS14.MapServer/Services/GitService.cs +++ b/SS14.MapServer/Services/GitService.cs @@ -108,6 +108,9 @@ private void Pull(string repoDirectory, string gitRef) _log.Debug("Updating submodules"); foreach (var submodule in repository.Submodules) { + if (submodule.UpdateRule == SubmoduleUpdate.None) + continue; + repository.Submodules.Update(submodule.Name, new SubmoduleUpdateOptions { OnProgress = LogProgress From 83ca8dd10e432285a7d6ec52fd4ad45195992d51 Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Fri, 8 Sep 2023 11:49:01 +0200 Subject: [PATCH 10/12] Set identity before git pulling Force git pull to ff only --- SS14.MapServer/Services/GitService.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/SS14.MapServer/Services/GitService.cs b/SS14.MapServer/Services/GitService.cs index c16d099..b0ade65 100644 --- a/SS14.MapServer/Services/GitService.cs +++ b/SS14.MapServer/Services/GitService.cs @@ -38,13 +38,11 @@ public string Sync(string workingDirectory, string? gitRef = null, string? repoU if (!Path.IsPathRooted(repoDirectory)) repoDirectory = Path.Join(Directory.GetCurrentDirectory(), repoDirectory); - if (!Directory.Exists(repoDirectory)) Clone(repoUrl, repoDirectory, gitRef); Pull(repoDirectory, gitRef); - return repoDirectory; } @@ -96,6 +94,11 @@ private void Pull(string repoDirectory, string gitRef) _log.Debug("Opening repository in: {RepositoryPath}", repoDirectory); using var repository = new Repository(repoDirectory); + //Set a dummy identity + _log.Debug("Setting identity"); + repository.Config.Set("user.name", "ss14.mapserver"); + repository.Config.Set("user.email", "git@mapserver.localhost"); + _log.Debug("Fetching ref"); _buildService.Run(repoDirectory, "git", new List { "fetch origin", gitRef }).Wait(); @@ -103,7 +106,7 @@ private void Pull(string repoDirectory, string gitRef) Commands.Checkout(repository, StripRef(gitRef)); _log.Debug("Pulling latest changes"); - _buildService.Run(repoDirectory, "git", new List { "pull origin HEAD" }).Wait(); + _buildService.Run(repoDirectory, "git", new List { "pull origin HEAD --ff-only" }).Wait(); _log.Debug("Updating submodules"); foreach (var submodule in repository.Submodules) From 71c0d22c8f49ac53062992c40733b7b6e002aa2e Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Fri, 8 Sep 2023 18:17:17 +0200 Subject: [PATCH 11/12] Change fetching refs to be forced and allow updating the head --- SS14.MapServer/Services/GitService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SS14.MapServer/Services/GitService.cs b/SS14.MapServer/Services/GitService.cs index b0ade65..55cb7fa 100644 --- a/SS14.MapServer/Services/GitService.cs +++ b/SS14.MapServer/Services/GitService.cs @@ -1,4 +1,5 @@ using LibGit2Sharp; +using LibGit2Sharp.Handlers; using Serilog; using SS14.MapServer.BuildRunners; using SS14.MapServer.Configuration; @@ -100,7 +101,7 @@ private void Pull(string repoDirectory, string gitRef) repository.Config.Set("user.email", "git@mapserver.localhost"); _log.Debug("Fetching ref"); - _buildService.Run(repoDirectory, "git", new List { "fetch origin", gitRef }).Wait(); + _buildService.Run(repoDirectory, "git", new List { "fetch -fu origin", gitRef }).Wait(); _log.Debug("Checking out {Ref}", StripRef(gitRef)); Commands.Checkout(repository, StripRef(gitRef)); From f6fdf84689f4acc9290607c116dc327a5faadf45 Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Wed, 20 Sep 2023 22:48:45 +0200 Subject: [PATCH 12/12] Add manual action for creating a dev docker image --- .github/workflows/deploy-dev-image.yml | 82 ++++++++++++++++++++++++++ .github/workflows/deploy.yml | 2 +- 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy-dev-image.yml diff --git a/.github/workflows/deploy-dev-image.yml b/.github/workflows/deploy-dev-image.yml new file mode 100644 index 0000000..eb1079a --- /dev/null +++ b/.github/workflows/deploy-dev-image.yml @@ -0,0 +1,82 @@ +name: Dev Deploy + +on: + workflow_dispatch: + branches: + - development + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + deploy-sentry: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.x.x + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --no-restore -c Release -p:SentryOrg=sentry -p:SentryProject=ss14-map-server -p:SentryUploadSymbols=true -p:SentryUploadSources=true -p:SentryUrl=https://bugs.tanukij.dev + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + + deploy-container: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + + - name: Docker Login + uses: docker/login-action@v2.2.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: get-net-sdk-project-versions-action + uses: kzrnm/get-net-sdk-project-versions-action@v1.3.0 + id: get-version + with: + proj-path: SS14.MapServer/SS14.MapServer.csproj + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.6.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=development + + - name: Build and push Docker image + uses: docker/build-push-action@v4.1.1 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + ci-success: + name: Deploy finished + needs: + - deploy-sentry + - deploy-container + runs-on: ubuntu-latest + steps: + - name: CI succeeded + run: exit 0 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dcb46b9..d94f791 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Build & Test +name: Deploy on: push: