Browse Source

feat(Workflow) Now have a testing part of deploy workflow

main
Jonathan McCaffrey 4 years ago
parent
commit
156339786c
  1. 31
      .github/workflows/development.yml
  2. 2
      .github/workflows/production.yml
  3. 25
      .github/workflows/test-development.yml
  4. 2
      TestAutomation/TestAutomation.csproj
  5. 11
      TestAutomation/UnitTest1.cs

31
.github/workflows/development.yml

@ -1,4 +1,4 @@
name: Azure Static Web Apps CI/CD name: Deploy To Development
on: on:
push: push:
@ -11,11 +11,11 @@ on:
jobs: jobs:
build_and_deploy_job: build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') if: github.event_name == 'push'
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Build and Deploy Job name: Build and Deploy Job
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
submodules: true submodules: true
- name: Build And Deploy - name: Build And Deploy
@ -29,14 +29,21 @@ jobs:
api_location: "" api_location: ""
output_location: "./wwwroot" output_location: "./wwwroot"
close_pull_request_job: test_deployed_website:
if: github.event_name == 'pull_request' && github.event.action == 'closed' name: Test Deployed Website
needs: build_and_deploy_job
if: github.event_name == 'push'
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Close Pull Request Job defaults:
run:
working-directory: ./TestAutomation
steps: steps:
- name: Close Pull Request - uses: browser-actions/setup-geckodriver@latest
id: closepullrequest - uses: actions/checkout@v3
uses: Azure/static-web-apps-deploy@v1 - name: Setup .NET
with: uses: actions/setup-dotnet@v2
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_CALM_MUD_04916B210 }} with:
action: "close" dotnet-version: 6.0.*
- run: dotnet restore
- run: dotnet build --no-restore
- run: dotnet test --no-build --verbosity normal

2
.github/workflows/production.yml

@ -1,4 +1,4 @@
name: Azure Static Web Apps CI/CD name: Deploy To Production
on: on:
push: push:

25
.github/workflows/test-development.yml

@ -0,0 +1,25 @@
name: Run Development Tests
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
tags:
description: 'Test scenario tags'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 5.0.x
- name: Change Directory
run: cd TestAutomation | dotnet restore |dotnet build --no-restore | dotnet test --no-build --verbosity normal

2
TestAutomation/TestAutomation.csproj

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>

11
TestAutomation/UnitTest1.cs

@ -11,16 +11,19 @@ public class Tests
private Website Website { get; } private Website Website { get; }
public Tests() { public Tests() {
//var options = new FirefoxOptions(); var options = new FirefoxOptions();
var options = new ChromeOptions(); //var options = new ChromeOptions();
options.AcceptInsecureCertificates = true; options.AcceptInsecureCertificates = true;
options.AddArgument("--headless"); options.AddArgument("--headless");
options.AddArgument("--ignore-certificate-errors");
options.AddArgument("--start-maximized"); options.AddArgument("--start-maximized");
options.AddArgument("--test-type");
options.AddArgument("--allow-running-insecure-content");
//_webDriver = new FirefoxDriver(options); //_webDriver = new FirefoxDriver(options);
_webDriver = new ChromeDriver(Environment.CurrentDirectory, options); //_webDriver = new ChromeDriver(Environment.CurrentDirectory, options);
//_webDriver = new FirefoxDriver(Environment.CurrentDirectory, options); _webDriver = new FirefoxDriver(Environment.CurrentDirectory, options);
Website = new Website(_webDriver); Website = new Website(_webDriver);

Loading…
Cancel
Save