Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add reusable start dev API action (#2413)
Leendert de Borst648f7ed249c2
diff --git a/.github/actions/start-api-server/action.yml b/.github/actions/start-api-server/action.ymlnew file mode 100644index 000000000..b0794eb9f--- /dev/null+++ b/.github/actions/start-api-server/action.yml@@ -0,0 +1,56 @@+name: "Start API Server"+description: "Sets up .NET, builds AliasVault.Api and starts it in the background on port 5100 against an existing PostgreSQL database"+inputs:+ database:+ description: "Name of the PostgreSQL database the API uses (created by EF migrations on startup if it does not exist)"+ required: true+ db-port:+ description: "Port PostgreSQL listens on (5109 for ./scripts/dev.sh db-start, 5432 for a runner-installed PostgreSQL)"+ required: false+ default: "5109"++outputs:+ log-file:+ description: "Path of the API server log"+ value: /tmp/api-server.log++runs:+ using: "composite"+ steps:+ - name: Setup .NET+ uses: actions/setup-dotnet@v5+ with:+ dotnet-version: 10.0.x++ - name: Build API server+ shell: bash+ working-directory: apps/server+ run: dotnet build AliasVault.Api++ - name: Start API server+ shell: bash+ working-directory: apps/server/AliasVault.Api+ run: |+ dotnet run --no-build > /tmp/api-server.log 2>&1 &+ echo "Waiting for API to start..."+ for i in {1..30}; do+ # Any HTTP response, even a 404, means the server is up.+ if curl -s -o /dev/null http://localhost:5100/; then+ echo "API is ready!"+ exit 0+ fi+ echo "Attempt $i: API not ready yet..."+ sleep 2+ done+ echo "::error::API did not start within 60 seconds"+ tail -n 100 /tmp/api-server.log+ exit 1+ env:+ ConnectionStrings__AliasServerDbContext: "Host=localhost;Port=${{ inputs.db-port }};Database=${{ inputs.database }};Username=aliasvault;Password=password"+ JWT_KEY: "12345678901234567890123456789012"+ DATA_PROTECTION_CERT_PASS: "Development"+ PUBLIC_REGISTRATION_ENABLED: "true"+ ADMIN_PASSWORD_HASH: "AQAAAAIAAYagAAAAEKWfKfa2gh9Z72vjAlnNP1xlME7FsunRznzyrfqFte40FToufRwa3kX8wwDwnEXZag=="+ ADMIN_PASSWORD_GENERATED: "2024-01-01T00:00:00Z"+ # All interfaces, so the Android emulator can reach it via 10.0.2.2.+ ASPNETCORE_URLS: "http://0.0.0.0:5100"diff --git a/.github/workflows/e2e-tests-android.yml b/.github/workflows/e2e-tests-android.ymlindex d55a1b1ca..ee7ebac15 100644--- a/.github/workflows/e2e-tests-android.yml+++ b/.github/workflows/e2e-tests-android.yml@@ -8,12 +8,14 @@ on:- 'apps/mobile-app/**'- 'core/**'- '.github/workflows/e2e-tests-android.yml'+ - '.github/actions/start-api-server/**'pull_request:branches: [ "main" ]paths:- 'apps/mobile-app/**'- 'core/**'- '.github/workflows/e2e-tests-android.yml'+ - '.github/actions/start-api-server/**'workflow_dispatch:concurrency:@@ -57,11 +59,6 @@ jobs:cache: 'npm'cache-dependency-path: apps/mobile-app/package-lock.json- - name: Setup .NET- uses: actions/setup-dotnet@v5- with:- dotnet-version: 9.0.x-- name: Setup Rust toolchainuses: dtolnay/rust-toolchain@stablewith:@@ -92,10 +89,6 @@ jobs:- name: Install mobile app dependenciesrun: npm ci- - name: Build API server- working-directory: apps/server- run: dotnet build AliasVault.Api-- name: Start PostgreSQLrun: |sudo systemctl start postgresql@@ -104,28 +97,10 @@ jobs:sudo -u postgres createdb -O aliasvault aliasdb_e2e_android || true- name: Start API server- working-directory: apps/server/AliasVault.Api- run: |- dotnet run --no-build > /tmp/api-server.log 2>&1 &- # Wait for API to be ready- echo "Waiting for API to start..."- for i in {1..30}; do- if curl -s http://localhost:5100/v1/ > /dev/null 2>&1; then- echo "API is ready!"- break- fi- echo "Attempt $i: API not ready yet..."- sleep 2- done- env:- ConnectionStrings__AliasServerDbContext: "Host=localhost;Port=5432;Database=aliasdb_e2e_android;Username=aliasvault;Password=password"- JWT_KEY: "12345678901234567890123456789012"- DATA_PROTECTION_CERT_PASS: "Development"- PUBLIC_REGISTRATION_ENABLED: "true"- ADMIN_PASSWORD_HASH: "AQAAAAIAAYagAAAAEKWfKfa2gh9Z72vjAlnNP1xlME7FsunRznzyrfqFte40FToufRwa3kX8wwDwnEXZag=="- ADMIN_PASSWORD_GENERATED: "2024-01-01T00:00:00Z"- # Bind to all interfaces (IPv4 and IPv6)- ASPNETCORE_URLS: "http://0.0.0.0:5100"+ uses: ./.github/actions/start-api-server+ with:+ database: aliasdb_e2e_android+ db-port: "5432"- name: Enable KVMrun: |diff --git a/.github/workflows/e2e-tests-browser-extension.yml b/.github/workflows/e2e-tests-browser-extension.ymlindex 6a5a672ad..02672edc0 100644--- a/.github/workflows/e2e-tests-browser-extension.yml+++ b/.github/workflows/e2e-tests-browser-extension.yml@@ -8,12 +8,14 @@ on:- 'apps/browser-extension/**'- 'core/**'- '.github/workflows/e2e-tests-browser-extension.yml'+ - '.github/actions/start-api-server/**'pull_request:branches: [ "main" ]paths:- 'apps/browser-extension/**'- 'core/**'- '.github/workflows/e2e-tests-browser-extension.yml'+ - '.github/actions/start-api-server/**'workflow_dispatch:concurrency:@@ -100,11 +102,6 @@ jobs:steps:- uses: actions/checkout@v6- - name: Setup .NET- uses: actions/setup-dotnet@v5- with:- dotnet-version: 9.0.x-- name: Setup Node.jsuses: actions/setup-node@v6with:@@ -134,38 +131,13 @@ jobs:chmod +x build-and-distribute.sh./build-and-distribute.sh --browser-extension- - name: Install .NET dependencies- working-directory: apps/server- run: dotnet workload install wasm-tools-- - name: Build API server- working-directory: apps/server- run: dotnet build AliasVault.Api-- name: Start dev databaserun: ./scripts/dev.sh db-start- name: Start API server- working-directory: apps/server/AliasVault.Api- run: |- dotnet run --no-build &- # Wait for API to be ready- echo "Waiting for API to start..."- for i in {1..30}; do- if curl -s http://localhost:5100/v1/Auth/status > /dev/null 2>&1; then- echo "API is ready!"- break- fi- echo "Attempt $i: API not ready yet..."- sleep 2- done- env:- ConnectionStrings__AliasServerDbContext: "Host=localhost;Port=5109;Database=aliasdb_e2e_extension;Username=aliasvault;Password=password"- JWT_KEY: "12345678901234567890123456789012"- DATA_PROTECTION_CERT_PASS: "Development"- PUBLIC_REGISTRATION_ENABLED: "true"- ADMIN_PASSWORD_HASH: "AQAAAAIAAYagAAAAEKWfKfa2gh9Z72vjAlnNP1xlME7FsunRznzyrfqFte40FToufRwa3kX8wwDwnEXZag=="- ADMIN_PASSWORD_GENERATED: "2024-01-01T00:00:00Z"+ uses: ./.github/actions/start-api-server+ with:+ database: aliasdb_e2e_extension- name: Install browser extension dependenciesrun: npm ci@@ -181,7 +153,7 @@ jobs:with:timeout_minutes: 60max_attempts: 3- command: cd apps/browser-extension && xvfb-run --auto-servernum npm run test:e2e:build+ command: cd apps/browser-extension && npm run test:e2e:buildenv:ALIASVAULT_API_URL: "http://localhost:5100"@@ -200,3 +172,12 @@ jobs:name: browser-extension-playwright-test-resultspath: apps/browser-extension/tests/test-results/retention-days: 30++ - name: Upload API server log on failure+ if: failure()+ uses: actions/upload-artifact@v7+ with:+ name: browser-extension-api-server-log+ path: /tmp/api-server.log+ retention-days: 30+ if-no-files-found: ignorediff --git a/.github/workflows/e2e-tests-ios.yml b/.github/workflows/e2e-tests-ios.ymlindex c350ab4a1..7e3bbe419 100644--- a/.github/workflows/e2e-tests-ios.yml+++ b/.github/workflows/e2e-tests-ios.yml@@ -8,12 +8,14 @@ on:- 'apps/mobile-app/**'- 'core/**'- '.github/workflows/e2e-tests-ios.yml'+ - '.github/actions/start-api-server/**'pull_request:branches: [ "main" ]paths:- 'apps/mobile-app/**'- 'core/**'- '.github/workflows/e2e-tests-ios.yml'+ - '.github/actions/start-api-server/**'workflow_dispatch:concurrency:@@ -45,11 +47,6 @@ jobs:cache: 'npm'cache-dependency-path: apps/mobile-app/package-lock.json- - name: Setup .NET- uses: actions/setup-dotnet@v5- with:- dotnet-version: 9.0.x-- name: Setup Rust toolchainuses: dtolnay/rust-toolchain@stablewith:@@ -83,10 +80,6 @@ jobs:cd iospod install- - name: Build API server- working-directory: apps/server- run: dotnet build AliasVault.Api-- name: Start PostgreSQLrun: |# Install and start PostgreSQL@@ -113,28 +106,10 @@ jobs:/opt/homebrew/opt/postgresql@17/bin/createdb -O aliasvault aliasdb_e2e_ios || true- name: Start API server- working-directory: apps/server/AliasVault.Api- run: |- dotnet run --no-build &- # Wait for API to be ready- echo "Waiting for API to start..."- for i in {1..30}; do- if curl -s http://localhost:5100/v1/ > /dev/null 2>&1; then- echo "API is ready!"- break- fi- echo "Attempt $i: API not ready yet..."- sleep 2- done- env:- ConnectionStrings__AliasServerDbContext: "Host=localhost;Port=5432;Database=aliasdb_e2e_ios;Username=aliasvault;Password=password"- JWT_KEY: "12345678901234567890123456789012"- DATA_PROTECTION_CERT_PASS: "Development"- PUBLIC_REGISTRATION_ENABLED: "true"- ADMIN_PASSWORD_HASH: "AQAAAAIAAYagAAAAEKWfKfa2gh9Z72vjAlnNP1xlME7FsunRznzyrfqFte40FToufRwa3kX8wwDwnEXZag=="- ADMIN_PASSWORD_GENERATED: "2024-01-01T00:00:00Z"- # Bind to all interfaces (IPv4 and IPv6)- ASPNETCORE_URLS: "http://0.0.0.0:5100"+ uses: ./.github/actions/start-api-server+ with:+ database: aliasdb_e2e_ios+ db-port: "5432"- name: Boot iOS Simulatorrun: |