From a44d6811a1324eb207ed0b02ab1c4e9e5e37a77d Mon Sep 17 00:00:00 2001 From: Nish26 Date: Sun, 1 May 2022 13:07:35 +0530 Subject: [PATCH] integration-tests-with-github-actions --- .config/identity-mongo-with-console-email.env | 17 ++++ .../identity-postgres-with-console-email.env | 16 ++++ .../identity-build-and-test-docker.yaml | 84 +++++++++---------- .github/workflows/identity-build-only.yaml | 14 ++-- Pixel.Identity.sln | 4 +- docker-compose.dcproj | 2 + 6 files changed, 83 insertions(+), 54 deletions(-) create mode 100644 .config/identity-mongo-with-console-email.env create mode 100644 .config/identity-postgres-with-console-email.env diff --git a/.config/identity-mongo-with-console-email.env b/.config/identity-mongo-with-console-email.env new file mode 100644 index 0000000..82564e7 --- /dev/null +++ b/.config/identity-mongo-with-console-email.env @@ -0,0 +1,17 @@ +#Note __ will be replaced to : by asp.net + +#Plugin configuration +Plugins__Collection__0__Type=EmailSender +Plugins__Collection__0__Path=Plugins/Messenger +Plugins__Collection__0__Name=Pixel.Identity.Messenger.Console +Plugins__Collection__1__Type=DbStore +Plugins__Collection__1__Path=Plugins/DbStore +Plugins__Collection__1__Name=Pixel.Identity.Store.Mongo + +IdentityOptions_SignIn_RequireConfirmedAccount=false +MongoDbSettings__ConnectionString=mongodb://mongoadmin:mongopass@mongo:27017/ +MongoDbSettings__DatabaseName=pixel-identity-db + +#Key for encryption certificate and signing certificate if any provided while generating them +Identity__Certificates__EncryptionCertificateKey="" +Identity__Certificates__SigningCertificateKey="" diff --git a/.config/identity-postgres-with-console-email.env b/.config/identity-postgres-with-console-email.env new file mode 100644 index 0000000..29b3d89 --- /dev/null +++ b/.config/identity-postgres-with-console-email.env @@ -0,0 +1,16 @@ +#Note __ will be replaced to : by asp.net + +#Plugin configuration +Plugins__Collection__0__Type=EmailSender +Plugins__Collection__0__Path=Plugins/Messenger +Plugins__Collection__0__Name=Pixel.Identity.Messenger.Console +Plugins__Collection__1__Type=DbStore +Plugins__Collection__1__Path=Plugins/DbStore +Plugins__Collection__1__Name=Pixel.Identity.Store.PostgreSQL + +IdentityOptions_SignIn_RequireConfirmedAccount=false +ConnectionStrings__PostgreServerConnection=User ID=postgresadmin;Password=postgrespass;Server=postgres;Port=5432;Database=pixel_identity_db; + +#Key for encryption certificate and signing certificate if any provided while generating them +Identity__Certificates__EncryptionCertificateKey="" +Identity__Certificates__SigningCertificateKey="" diff --git a/.github/workflows/identity-build-and-test-docker.yaml b/.github/workflows/identity-build-and-test-docker.yaml index f241e99..e335279 100644 --- a/.github/workflows/identity-build-and-test-docker.yaml +++ b/.github/workflows/identity-build-and-test-docker.yaml @@ -5,38 +5,32 @@ on: jobs: - build-docker-image-and-push: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write + build-docker-image: + runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v3 - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push + uses: actions/checkout@v3 + - name: Build docker image locally uses: docker/build-push-action@v2 with: - context: . + context: ./ file: ./src/Pixel.Identity.Provider/Dockerfile - push: true - tags: pixel-identity:latest + push: false + tags: pixel-identity:latest + load: true + - name: Upload docker image as artifcat + uses: ishworkh/docker-image-artifact-upload@v1 + with: + image: "pixel-identity:latest" - test-postgres: - - needs: build-docker-image-and-push + test-with-postgres-db: + needs: build-docker-image runs-on: ubuntu-latest strategy: matrix: dotnet-version: [ '6.0.x' ] services: - postgres: image: postgres:latest env: @@ -50,36 +44,36 @@ jobs: --health-retries 5 ports: - 5432:5432 - - pixel-identity: - image: pixel-identity:latest - env: - AllowedOrigins: http://localhost:5000 - IdentityHost: http://localhost:5000/pauth - ASPNETCORE_URLS: http://+ - Plugins__Collection__0__Type: EmailSender - Plugins__Collection__0__Path: Plugins/Messenger - Plugins__Collection__0__Name: Pixel.Identity.Messenger.Console - Plugins__Collection__1__Type: DbStore - Plugins__Collection__1__Path: Plugins/DbStore - Plugins__Collection__1__Name: Pixel.Identity.Store.PostgreSQL - IdentityOptions_SignIn_RequireConfirmedAccount: false - ConnectionStrings__PostgreServerConnection: User ID=postgresadmin;Password=postgrespass;Server=postgres;Port=5432;Database=pixel_identity_db; + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Download docker image + uses: ishworkh/docker-image-artifact-download@v1 + with: + image: "pixel-identity:latest" + - name: Launch docker image + run: > + docker run -d -p 44382:80 --network=${{ job.container.network }} + -e AllowedOrigins=http://localhost:44382 -e IdentityHost=http://localhost:44382/pauth + --env-file ./.config/identity-postgres-with-console-email.env + --name pixel_identity_provider pixel-identity:latest + - name: Print container details + run: docker container ls - name: Setup dotnet ${{ matrix.dotnet-version }} uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{ matrix.dotnet-version }} - - name: Build test project - env: - BROWSER: Chromium - HEADED: 1 - BaseUrl: http://localhost:5000//pauth - UserEmail: admin@pixel.com - UserSecret: Admi9@pixel + dotnet-version: ${{ matrix.dotnet-version }} + - name: Build test project run: dotnet build src/Pixel.Identity.UI.Tests/Pixel.Identity.UI.Tests.csproj + - name: print container logs + run: docker logs pixel_identity_provider - name: Install browsers run: pwsh src/Pixel.Identity.UI.Tests/bin/Debug/net6.0/playwright.ps1 install - name: Execute tests - run: dotnet test src/Pixel.Identity.UI.Tests/Pixel.Identity.UI.Tests.csproj - + run: dotnet test --logger "trx;" src/Pixel.Identity.UI.Tests/Pixel.Identity.UI.Tests.csproj + - name: Upload test results + uses: actions/upload-artifact@v3 + with: + name: pixel-identity-automation-test-results-${{ matrix.os }} + path: src/Pixel.Identity.UI.Tests/TestResults \ No newline at end of file diff --git a/.github/workflows/identity-build-only.yaml b/.github/workflows/identity-build-only.yaml index de16b7a..1ae4539 100644 --- a/.github/workflows/identity-build-only.yaml +++ b/.github/workflows/identity-build-only.yaml @@ -14,9 +14,10 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: [ubuntu-latest, windows-latest] dotnet-version: [ '6.0.x' ] steps: @@ -36,12 +37,11 @@ jobs: - name: Display dotnet version run: dotnet --version - name: Install dependencies - run: dotnet restore Pixel.Identity.sln - - name: Build - run: dotnet build src/Pixel.Identity.Provider/Pixel.Identity.Provider.csproj -c Release --no-restore -o app/build + run: dotnet restore Pixel.Identity.sln + - name: Publish + run: dotnet publish src/Pixel.Identity.Provider/Pixel.Identity.Provider.csproj -c Release --no-restore -o app/publish - name: Upload build artifacts uses: actions/upload-artifact@v3 with: - name: Pixel Identity - path: app/build - + name: pixel-identity-${{ matrix.os }} + path: app/publish diff --git a/Pixel.Identity.sln b/Pixel.Identity.sln index 759b198..0a4dbe7 100644 --- a/Pixel.Identity.sln +++ b/Pixel.Identity.sln @@ -41,8 +41,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{2454 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{1872169C-F107-43FD-AE02-6DDF88241644}" ProjectSection(SolutionItems) = preProject - .github\workflows\identity-build-and-test.yaml = .github\workflows\identity-build-and-test.yaml - .github\workflows\identity-build-docker.yaml = .github\workflows\identity-build-docker.yaml + .github\workflows\identity-build-and-test-docker.yaml = .github\workflows\identity-build-and-test-docker.yaml + .github\workflows\identity-build-only.yaml = .github\workflows\identity-build-only.yaml EndProjectSection EndProject Global diff --git a/docker-compose.dcproj b/docker-compose.dcproj index 9e769d8..4cd117b 100644 --- a/docker-compose.dcproj +++ b/docker-compose.dcproj @@ -10,6 +10,8 @@ + +