diff --git a/.github/workflows/docker-compose-build.yml b/.github/workflows/docker-compose-build.yml index a832b2b96..85656da2f 100644 --- a/.github/workflows/docker-compose-build.yml +++ b/.github/workflows/docker-compose-build.yml @@ -9,61 +9,80 @@ on: jobs: test-docker: runs-on: ubuntu-latest + services: docker: image: docker:26.0.0 options: --privileged + steps: - uses: actions/checkout@v2 - name: Set permissions and run install.sh run: | chmod +x install.sh ./install.sh + - name: Set up Docker Compose run: | # Change the exposed host port of the SmtpService from 25 to 2525 because port 25 is not allowed in GitHub Actions sed -i 's/25\:25/2525\:25/g' docker-compose.yml docker compose -f docker-compose.yml up -d + - name: Wait for services to be up run: | # Wait for a few seconds - sleep 5 - - name: Test if localhost:80 (WASM app) responds - run: | - # Test if the service on localhost:80 responds - http_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:80) - if [ "$http_code" -ne 200 ]; then - echo "Service did not respond with 200 OK. Check if client app is configured correctly." - exit 1 - else - echo "Service responded with 200 OK" - fi - - name: Test if localhost:81 (WebApi) responds - run: | - # Test if the service on localhost:81 responds - http_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:81) - if [ "$http_code" -ne 200 ]; then - echo "Service did not respond with expected 200 OK. Check if WebApi is configured correctly." - exit 1 - else - echo "Service responded with $http_code" - fi - - name: Test if localhost:2525 (SmtpService) responds - run: | - # Test if the service on localhost:2525 responds - if ! nc -zv localhost 2525 2>&1 | grep -q 'succeeded'; then - echo "SmtpService did not respond on port 2525. Check if the SmtpService service is running." - exit 1 - else - echo "SmtpService responded on port 2525" - fi - - name: Test if localhost:8080 (Admin) responds - run: | - # Test if the service on localhost:8080 responds - http_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/user/login) - if [ "$http_code" -ne 200 ]; then - echo "Service did not respond with expected 200 OK. Check if admin app is configured correctly." - exit 1 - else - echo "Service responded with $http_code" - fi + sleep 10 + - name: Test if localhost:80 (WASM app) responds + uses: nick-fields/retry@v3 + with: + timeout_minutes: 2 + max_attempts: 3 + command: | + http_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:80) + if [ "$http_code" -ne 200 ]; then + echo "Service did not respond with 200 OK. Check if client app is configured correctly." + exit 1 + else + echo "Service responded with 200 OK" + fi + + - name: Test if localhost:81 (WebApi) responds + uses: nick-fields/retry@v3 + with: + timeout_minutes: 2 + max_attempts: 3 + command: | + http_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:81) + if [ "$http_code" -ne 200 ]; then + echo "Service did not respond with expected 200 OK. Check if WebApi is configured correctly." + exit 1 + else + echo "Service responded with $http_code" + fi + + - name: Test if localhost:2525 (SmtpService) responds + uses: nick-fields/retry@v3 + with: + timeout_minutes: 2 + max_attempts: 3 + command: | + if ! nc -zv localhost 2525 2>&1 | grep -q 'succeeded'; then + echo "SmtpService did not respond on port 2525. Check if the SmtpService service is running." + exit 1 + else + echo "SmtpService responded on port 2525" + fi + + - name: Test if localhost:8080 (Admin) responds + uses: nick-fields/retry@v3 + with: + timeout_minutes: 2 + max_attempts: 3 + command: | + http_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/user/login) + if [ "$http_code" -ne 200 ]; then + echo "Service did not respond with expected 200 OK. Check if admin app is configured correctly." + exit 1 + else + echo "Service responded with $http_code" + fi diff --git a/.github/workflows/dotnet-e2e-tests.yml b/.github/workflows/dotnet-e2e-tests.yml index 659155904..fd6ceb7c7 100644 --- a/.github/workflows/dotnet-e2e-tests.yml +++ b/.github/workflows/dotnet-e2e-tests.yml @@ -15,33 +15,37 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x + - name: Install dependencies run: dotnet workload install wasm-tools + - name: Build run: dotnet build + - name: Ensure browsers are installed run: pwsh src/Tests/AliasVault.E2ETests/bin/Debug/net8.0/playwright.ps1 install --with-deps - name: Run AdminTests with retry - uses: nick-invision/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 10 max_attempts: 3 command: dotnet test src/Tests/AliasVault.E2ETests --no-build --verbosity normal --filter "Category=AdminTests" - name: Run ClientTests with retry - uses: nick-invision/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 10 max_attempts: 3 command: dotnet test src/Tests/AliasVault.E2ETests --no-build --verbosity normal --filter "Category=ClientTests" - name: Run remaining tests with retry - uses: nick-invision/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 10 max_attempts: 3 diff --git a/.github/workflows/dotnet-integration-tests.yml b/.github/workflows/dotnet-integration-tests.yml index 31330a2e3..76e87bf83 100644 --- a/.github/workflows/dotnet-integration-tests.yml +++ b/.github/workflows/dotnet-integration-tests.yml @@ -15,13 +15,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x + - name: Install dependencies run: dotnet workload install wasm-tools + - name: Build run: dotnet build + - name: Run integration tests run: dotnet test src/Tests/AliasVault.IntegrationTests --no-build --verbosity normal diff --git a/.github/workflows/dotnet-unit-tests.yml b/.github/workflows/dotnet-unit-tests.yml index 75314608b..3ee628f2c 100644 --- a/.github/workflows/dotnet-unit-tests.yml +++ b/.github/workflows/dotnet-unit-tests.yml @@ -14,15 +14,20 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x + - name: Install dependencies run: dotnet workload install wasm-tools + - name: Restore dependencies run: dotnet restore + - name: Build run: dotnet build --no-restore + - name: Run unittests run: dotnet test src/Tests/AliasVault.UnitTests --no-build --verbosity normal diff --git a/.github/workflows/sonarcloud-code-analysis.yml b/.github/workflows/sonarcloud-code-analysis.yml index f5c365a03..2e14aaab7 100644 --- a/.github/workflows/sonarcloud-code-analysis.yml +++ b/.github/workflows/sonarcloud-code-analysis.yml @@ -15,15 +15,18 @@ jobs: with: java-version: 17 distribution: 'zulu' # Alternative distribution options are available. + - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Cache SonarCloud packages uses: actions/cache@v3 with: path: ~\sonar\cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar + - name: Cache SonarCloud scanner id: cache-sonar-scanner uses: actions/cache@v3 @@ -31,15 +34,17 @@ jobs: path: .\.sonar\scanner key: ${{ runner.os }}-sonar-scanner restore-keys: ${{ runner.os }}-sonar-scanner + - name: Install SonarCloud scanner if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' shell: powershell run: | New-Item -Path .\.sonar\scanner -ItemType Directory dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner + - name: Build and analyze env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} shell: powershell run: | diff --git a/src/AliasVault.Client/Dockerfile b/src/AliasVault.Client/Dockerfile index a70540c77..0f47633e1 100644 --- a/src/AliasVault.Client/Dockerfile +++ b/src/AliasVault.Client/Dockerfile @@ -21,7 +21,7 @@ COPY ["src/AliasGenerators/AliasGenerators.csproj", "src/AliasGenerators/"] COPY ["src/Utilities/FaviconExtractor/FaviconExtractor.csproj", "src/Utilities/FaviconExtractor/"] RUN dotnet restore "src/AliasVault.Client/AliasVault.Client.csproj" -# Copy the rest of the application code +# Copy the application code COPY . . # Build the Client project