Skip to content

Commit

Permalink
integration-tests-with-github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nfactor26 committed May 1, 2022
1 parent ccb74a6 commit a44d681
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 54 deletions.
17 changes: 17 additions & 0 deletions .config/identity-mongo-with-console-email.env
Original file line number Diff line number Diff line change
@@ -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=""
16 changes: 16 additions & 0 deletions .config/identity-postgres-with-console-email.env
Original file line number Diff line number Diff line change
@@ -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=""
84 changes: 39 additions & 45 deletions .github/workflows/identity-build-and-test-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: [email protected]
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
14 changes: 7 additions & 7 deletions .github/workflows/identity-build-only.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
4 changes: 2 additions & 2 deletions Pixel.Identity.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.dcproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
</PropertyGroup>
<ItemGroup>
<None Include=".config\identity.env" />
<None Include=".config\identity-mongo-with-console-email.env" />
<None Include=".config\identity-postgres-with-console-email.env" />
<None Include=".traefik\config.yml" />
<None Include=".traefik\traefik.yml" />
<None Include="docker-compose.override.yml">
Expand Down

0 comments on commit a44d681

Please sign in to comment.