From 46a327aa71fc4d529416381a3afd0e432a55b4a8 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Fri, 7 Jun 2024 12:46:00 -0600 Subject: [PATCH 1/6] enable oauth in develop (and init container) --- deployment/base/app-config.yaml | 1 + deployment/base/lexbox-deployment.yaml | 10 ++++++++++ deployment/develop/app-config.yaml | 1 + deployment/develop/lexbox-deployment.patch.yaml | 2 -- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/deployment/base/app-config.yaml b/deployment/base/app-config.yaml index 2cdf08cde..7a0103c97 100644 --- a/deployment/base/app-config.yaml +++ b/deployment/base/app-config.yaml @@ -6,4 +6,5 @@ data: environment-name: "Development" hg-otel-disabled: "false" # "true" to disable OpenTelemetry hg-domain: "hg.localhost" + enable-oauth: "false" diff --git a/deployment/base/lexbox-deployment.yaml b/deployment/base/lexbox-deployment.yaml index f70c72240..da2c22e73 100644 --- a/deployment/base/lexbox-deployment.yaml +++ b/deployment/base/lexbox-deployment.yaml @@ -180,6 +180,11 @@ spec: secretKeyRef: key: SMTP_PASSWORD name: email + - name: Authentication__OpenId__Enable + valueFrom: + configMapKeyRef: + name: app-config + key: enable-oauth - name: Authentication__Google__ClientId valueFrom: secretKeyRef: @@ -275,6 +280,11 @@ spec: configMapKeyRef: name: app-config key: environment-name + - name: Authentication__OpenId__Enable + valueFrom: + configMapKeyRef: + name: app-config + key: enable-oauth - name: set-repo-structure-owner-to-www-data securityContext: # Make sure we're authorized to set ownership diff --git a/deployment/develop/app-config.yaml b/deployment/develop/app-config.yaml index f0e1b2f3c..7dfe2725d 100644 --- a/deployment/develop/app-config.yaml +++ b/deployment/develop/app-config.yaml @@ -5,4 +5,5 @@ metadata: data: environment-name: "Development" hg-domain: "hg-develop.lexbox.org" + enable-oauth: "true" diff --git a/deployment/develop/lexbox-deployment.patch.yaml b/deployment/develop/lexbox-deployment.patch.yaml index ead50bc88..58d016e9c 100644 --- a/deployment/develop/lexbox-deployment.patch.yaml +++ b/deployment/develop/lexbox-deployment.patch.yaml @@ -16,8 +16,6 @@ spec: - name: ASPNETCORE_ENVIRONMENT value: "Staging" #we don't want to act like dev as that's for local development valueFrom: - - name: Authentication__OpenId__Enable - value: "true" - name: Email__SmtpHost value: email-smtp.us-east-1.amazonaws.com - name: Email__SmtpPort From 878cf353a0843bb51ffaea024224803d0eb7059e Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Fri, 7 Jun 2024 12:47:34 -0600 Subject: [PATCH 2/6] FW lite: change default authority to be lexbox develop, add task for running with the authority locally --- backend/LocalWebApp/LocalAppKernel.cs | 2 +- backend/LocalWebApp/Program.cs | 2 +- backend/Taskfile.yml | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/LocalWebApp/LocalAppKernel.cs b/backend/LocalWebApp/LocalAppKernel.cs index aa8090f9e..03e744710 100644 --- a/backend/LocalWebApp/LocalAppKernel.cs +++ b/backend/LocalWebApp/LocalAppKernel.cs @@ -49,7 +49,7 @@ private static void AddAuthHelpers(this IServiceCollection services, IHostEnviro services.AddTransient(sp => sp.GetRequiredService().GetCurrentHelper()); services.AddSingleton(); services.AddSingleton(sp => sp.GetRequiredService()); - services.AddOptionsWithValidateOnStart().ValidateDataAnnotations(); + services.AddOptionsWithValidateOnStart().BindConfiguration("Auth").ValidateDataAnnotations(); services.AddSingleton(); var httpClientBuilder = services.AddHttpClient(AuthHelpers.AuthHttpClientName); if (environment.IsDevelopment()) diff --git a/backend/LocalWebApp/Program.cs b/backend/LocalWebApp/Program.cs index 961c6e80d..cf6c481b5 100644 --- a/backend/LocalWebApp/Program.cs +++ b/backend/LocalWebApp/Program.cs @@ -9,7 +9,7 @@ var builder = WebApplication.CreateBuilder(args); if (!builder.Environment.IsDevelopment()) builder.WebHost.UseUrls("http://127.0.0.1:0"); -builder.ConfigureDev(config => config.DefaultAuthority = new("https://localhost:3000")); +builder.ConfigureDev(config => config.DefaultAuthority = new("https://lexbox.dev.languagetechnology.org")); builder.ConfigureProd(config => config.DefaultAuthority = new("https://lexbox.org")); builder.Services.Configure(c => c.ClientId = "becf2856-0690-434b-b192-a4032b72067f"); diff --git a/backend/Taskfile.yml b/backend/Taskfile.yml index 1a4cf9fa5..21ac8a733 100644 --- a/backend/Taskfile.yml +++ b/backend/Taskfile.yml @@ -95,6 +95,12 @@ tasks: label: dotnet dir: ./LocalWebApp cmd: dotnet watch --no-hot-reload + local-web-app-with-local-lexbox: + label: Run LocalWebApp with Local LexBox + env: + Auth__DefaultAuthority: "https://localhost:3000" + dir: ./LocalWebApp + cmd: dotnet watch --no-hot-reload publish-local-all: cmds: From 9095361db3e2fc4691ce3328ca1f64c940dfbf15 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Fri, 7 Jun 2024 14:44:39 -0600 Subject: [PATCH 3/6] add fw lite workflow to output builds and run tests. Exclude fw lite stuff from lexbox-api.yaml workflow and don't run fw lite tests as part of lexbox. --- .github/workflows/develop-api.yaml | 16 ++++--- .github/workflows/fw-lite.yaml | 70 ++++++++++++++++++++++++++++++ .github/workflows/lexbox-api.yaml | 3 +- frontend/viewer/package.json | 4 ++ 4 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/fw-lite.yaml diff --git a/.github/workflows/develop-api.yaml b/.github/workflows/develop-api.yaml index 9a2d3ed01..974beea8b 100644 --- a/.github/workflows/develop-api.yaml +++ b/.github/workflows/develop-api.yaml @@ -2,19 +2,21 @@ name: Develop API CI/CD on: workflow_dispatch: push: - paths: - - 'backend/**' + paths: &paths + - 'backend/LexBoxApi/**' + - 'backend/LexCore/**' + - 'backend/LexData/**' + - 'backend/LfClassicData/**' + - 'backend/MiniLcm/**' + - 'backend/SyncReverserProxy/**' + - 'backend/Testing/**' - '.github/workflows/lexbox-api.yaml' - '.github/workflows/deploy.yaml' - 'deployment/lexbox-deployment.yaml' branches: - develop pull_request: - paths: - - 'backend/**' - - '.github/workflows/lexbox-api.yaml' - - '.github/workflows/deploy.yaml' - - 'deployment/lexbox-deployment.yaml' + paths: *paths branches: - develop diff --git a/.github/workflows/fw-lite.yaml b/.github/workflows/fw-lite.yaml new file mode 100644 index 000000000..e078f1759 --- /dev/null +++ b/.github/workflows/fw-lite.yaml @@ -0,0 +1,70 @@ +name: FieldWorks Lite +on: + workflow_dispatch: + push: + paths: &paths + - 'backend/FwDataMiniLcmBridge/**' + - 'backend/harmony/**' + - 'backend/LcmCrdt/**' + - 'backend/LocalWebApp/**' + - 'backend/MiniLcm/**' + - 'frontend/viewer/**' + - '.github/workflows/fw-lite.yaml' + branches: + - develop + pull_request: + paths: *paths + branches: + - develop + +jobs: + build-app: + name: Build FW Lite + timeout-minutes: 20 + runs-on: unutbu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.x' + - uses: actions/setup-node@v4 + with: + node-version-file: './frontend/package.json' + - name: Dotnet build + working-directory: backend/LocalWebApp + run: dotnet build --configuration Release + - name: Dotnet test + working-directory: backend/LcmCrdt.Tests + run: dotnet test --configuration Release --logger:"xunit;LogFileName={assembly}.results.xml" --results-directory ./test-results + - name: Publish test results + uses: EnricoMi/publish-unit-test-result-action@8885e273a4343cd7b48eaa72428dea0c3067ea98 # v2.14.0 + if: always() + with: + check_name: FW Lite Unit Tests + files: ./backend/LcmCrdt.Tests/test-results/*.xml + - name: Build viewer + working-directory: frontend/viewer + run: | + corepack enable + pnpm install + pnpm run build-app + + - name: Publish linux + working-directory: backend/LocalWebApp + run: dotnet publish -r linux-x64 -o ./publish/linux + - name: Publish osx + working-directory: backend/LocalWebApp + run: dotnet publish -r osx-x64 -o ./publish/osx + - name: Publish win + working-directory: backend/LocalWebApp + run: dotnet publish -r win-x64 -o ./publish/win + - name: Upload artifacts + # uploading in one artifact as there's a lot of duplication between builds so compression goes far + uses: actions/upload-artifact@v4 + with: + name: fw-lite + if-no-files-found: error + path: backend/LocalWebApp/publish/* diff --git a/.github/workflows/lexbox-api.yaml b/.github/workflows/lexbox-api.yaml index aecbedc84..372ab865e 100644 --- a/.github/workflows/lexbox-api.yaml +++ b/.github/workflows/lexbox-api.yaml @@ -53,13 +53,14 @@ jobs: - name: Dotnet build run: dotnet build - name: Unit tests + working-directory: backend/Testing run: dotnet test --logger:"xunit;LogFileName={assembly}.results.xml" --results-directory ./test-results --filter "Category!=Integration" --blame-hang-timeout 10m - name: Publish unit test results uses: EnricoMi/publish-unit-test-result-action@8885e273a4343cd7b48eaa72428dea0c3067ea98 # v2.14.0 if: always() with: check_name: C# Unit Tests - files: ./test-results/*.xml + files: ./backend/Testing/test-results/*.xml - name: Upload test results if: always() uses: actions/upload-artifact@v4 diff --git a/frontend/viewer/package.json b/frontend/viewer/package.json index 75798fdc3..7d7c82806 100644 --- a/frontend/viewer/package.json +++ b/frontend/viewer/package.json @@ -1,6 +1,10 @@ { "name": "viewer", "private": true, + "packageManager": "pnpm@8.15.1", + "engines": { + "node": ">=20" + }, "version": "1.0.0", "type": "module", "main": "dist-web-component/viewer.js", From c16ec9bb3f78152c11a8b992a629c630d5702fb2 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Fri, 7 Jun 2024 14:44:39 -0600 Subject: [PATCH 4/6] remove yaml anchors --- .github/workflows/develop-api.yaml | 14 ++++++++++++-- .github/workflows/fw-lite.yaml | 11 +++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/develop-api.yaml b/.github/workflows/develop-api.yaml index 974beea8b..8851e1a9b 100644 --- a/.github/workflows/develop-api.yaml +++ b/.github/workflows/develop-api.yaml @@ -2,7 +2,7 @@ name: Develop API CI/CD on: workflow_dispatch: push: - paths: &paths + paths: - 'backend/LexBoxApi/**' - 'backend/LexCore/**' - 'backend/LexData/**' @@ -16,7 +16,17 @@ on: branches: - develop pull_request: - paths: *paths + paths: + - 'backend/LexBoxApi/**' + - 'backend/LexCore/**' + - 'backend/LexData/**' + - 'backend/LfClassicData/**' + - 'backend/MiniLcm/**' + - 'backend/SyncReverserProxy/**' + - 'backend/Testing/**' + - '.github/workflows/lexbox-api.yaml' + - '.github/workflows/deploy.yaml' + - 'deployment/lexbox-deployment.yaml' branches: - develop diff --git a/.github/workflows/fw-lite.yaml b/.github/workflows/fw-lite.yaml index e078f1759..ab1dde37b 100644 --- a/.github/workflows/fw-lite.yaml +++ b/.github/workflows/fw-lite.yaml @@ -2,7 +2,7 @@ on: workflow_dispatch: push: - paths: &paths + paths: - 'backend/FwDataMiniLcmBridge/**' - 'backend/harmony/**' - 'backend/LcmCrdt/**' @@ -13,7 +13,14 @@ on: branches: - develop pull_request: - paths: *paths + paths: + - 'backend/FwDataMiniLcmBridge/**' + - 'backend/harmony/**' + - 'backend/LcmCrdt/**' + - 'backend/LocalWebApp/**' + - 'backend/MiniLcm/**' + - 'frontend/viewer/**' + - '.github/workflows/fw-lite.yaml' branches: - develop From 3983773dcbb53fda24ace269d5b097c628785d08 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Fri, 7 Jun 2024 15:54:11 -0600 Subject: [PATCH 5/6] fix spelling mistake in ubunut --- .github/workflows/fw-lite.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fw-lite.yaml b/.github/workflows/fw-lite.yaml index ab1dde37b..70cc22320 100644 --- a/.github/workflows/fw-lite.yaml +++ b/.github/workflows/fw-lite.yaml @@ -28,7 +28,7 @@ jobs: build-app: name: Build FW Lite timeout-minutes: 20 - runs-on: unutbu-latest + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 From 3e77c43a0d35881bf85ac9f1733dc716362ac6bb Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Fri, 7 Jun 2024 16:10:16 -0600 Subject: [PATCH 6/6] allow redirecting to 127.0.0.1 for FW lite client --- backend/LexData/SeedingData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/LexData/SeedingData.cs b/backend/LexData/SeedingData.cs index c61e3b288..e30c6368f 100644 --- a/backend/LexData/SeedingData.cs +++ b/backend/LexData/SeedingData.cs @@ -233,7 +233,7 @@ async ValueTask UpdateApp(object dbApp, OpenIddictApplicationDescriptor seedApp, OpenIddictConstants.Permissions.Scopes.Profile }, // port is dynamic due to the nature of the native app - RedirectUris = { new Uri("http://localhost:5173/api/auth/oauth-callback") } + RedirectUris = { new Uri("http://localhost:5173/api/auth/oauth-callback"), new Uri("http://127.0.0.1:5173/api/auth/oauth-callback") } } ], a => a.ClientId ?? throw new InvalidOperationException("ClientId is null"));