зеркало из
1
0
Форкнуть 0

fix: move the runtime config file under appLocation (#471)

* fix: move the runtime config file under appLocation

* ci: re-enable cypress on CICD

* ci: e2e using electron

* ci: add e2e workflow

* ci: update codeql
This commit is contained in:
Wassim Chegham 2022-05-18 13:27:07 +02:00 коммит произвёл GitHub
Родитель f27f68e5b6
Коммит 372f57d4e1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
16 изменённых файлов: 188 добавлений и 193 удалений

Просмотреть файл

@ -214,42 +214,8 @@ jobs:
cd cypress/fixtures/
swa deploy app --dry-run --verbose=silly --api-location=./static/api --app-location ./static --deployment-token=00000000000000000000000000000000000000000000000000000000000000000-00000000-0000-0000-0000-00000000000000000000
# TODO: Cypress setup is failing on CI. Investigate.
# e2e:
# needs: [test-macos, test-windows, test-linux]
# runs-on: ${{ matrix.os }}
# strategy:
# # when one test fails, DO NOT cancel the other
# # containers, because this will kill Cypress processes
# # https://github.com/cypress-io/github-action/issues/48
# fail-fast: false
# matrix:
# os: [macos-latest, windows-latest, ubuntu-20.04]
# node-version: [14.x]
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Cypress run
# uses: cypress-io/github-action@v2
# with:
# record: false
# start: npm run e2e:static
# browser: chrome
# headless: true
# wait-on: "http://0.0.0.0:1234, http://localhost:7071"
# wait-on-timeout: 120
# env:
# DEBUG: "cypress:*"
# - uses: actions/upload-artifact@v1
# if: failure()
# with:
# name: cypress-screenshots
# path: cypress/screenshots
package:
needs: [e2e-deploy-macos, e2e-deploy-windows, e2e-deploy-linux]
needs: [e2e-deploy-macos, e2e-deploy-linux, e2e-deploy-windows]
runs-on: ubuntu-20.04
steps:

6
.github/workflows/codeql-analysis.yml поставляемый
Просмотреть файл

@ -39,7 +39,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@ -50,7 +50,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@ -64,4 +64,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

35
.github/workflows/e2e.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,35 @@
name: E2E
on:
push:
branches: [main, ga]
pull_request:
branches: [main, ga]
jobs:
e2e:
runs-on: ${{ matrix.os }}
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-20.04]
node-version: [14.x, 15.x, 16.x, 17.x]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cypress run
uses: cypress-io/github-action@v2
with:
record: false
video: false
start: npm run e2e:static
wait-on: "http://0.0.0.0:1234, http://localhost:7071"
wait-on-timeout: 120
env:
DEBUG: "cypress:*"
CI: 1

Просмотреть файл

@ -1,5 +1,111 @@
{
"routes": [
{
"route": "/redirect/301",
"redirect": "/index2.html",
"statusCode": 301
},
{
"route": "/redirect/302",
"redirect": "/index2.html",
"statusCode": 302
},
{
"route": "/redirect/*",
"redirect": "/index2.html"
},
{
"route": "/redirect/*/invalid",
"statusCode": 418
},
{
"route": "/*.google",
"redirect": "https://www.google.com/"
},
{
"route": "/*.{jpg}",
"redirect": "/jpg.html"
},
{
"route": "*.foo",
"redirect": "/foo.html"
},
{
"route": "/*.{png,gif}",
"redirect": "/png_gif.html"
},
{
"route": "/folder/*.{html,xml}",
"rewrite": "/folder/"
},
{
"route": "/rewrite_index2",
"rewrite": "/index2.html",
"headers": {
"a": "c",
"foo": "bar"
}
},
{
"route": "/rewrite-to-function",
"rewrite": "/api/headers"
},
{
"route": "/login-github",
"rewrite": "/.auth/login/github"
},
{
"route": "/logout",
"rewrite": "/.auth/logout"
},
{
"route": "/.auth/login/aad",
"statusCode": 404
},
{
"route": "/status-code-401.txt",
"statusCode": 401
},
{
"route": "/status-code-403.txt",
"statusCode": 403
},
{
"route": "/status-code-404.txt",
"statusCode": 404
},
{
"route": "/only-authenticated",
"allowedRoles": ["authenticated"]
},
{
"route": "/api/info",
"allowedRoles": ["authenticated"]
},
{
"route": "/api/error",
"statusCode": 403
}
],
"navigationFallback": {
"rewrite": "/index.html"
"rewrite": "/index.html",
"exclude": ["*.{txt}"]
},
"responseOverrides": {
"401": {
"rewrite": "/custom-401.html"
},
"403": {
"rewrite": "/custom-403.html"
},
"404": {
"rewrite": "/custom-404.html"
}
},
"mimeTypes": {
".swaconfig": "application/json"
},
"globalHeaders": {
"a": "b"
}
}

Просмотреть файл

@ -1,11 +1,14 @@
{
"$schema": "../../../schema/swa-cli.config.schema.json",
"$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
"configurations": {
"app": {
"outputLocation": "http://localhost:5000",
"appLocation": ".",
"apiLocation": "./Api",
"run": "dotnet run --project ./Client",
"blazor-starter": {
"appLocation": "Client",
"apiLocation": "Api",
"outputLocation": "output",
"appBuildCommand": "dotnet build",
"apiBuildCommand": "dotnet build",
"run": "dotnet watch run",
"devServerUrl": "http://localhost:8000",
"port": 1234,
"host": "0.0.0.0",
"devserverTimeout": 100,

Просмотреть файл

@ -1,111 +0,0 @@
{
"routes": [
{
"route": "/redirect/301",
"redirect": "/index2.html",
"statusCode": 301
},
{
"route": "/redirect/302",
"redirect": "/index2.html",
"statusCode": 302
},
{
"route": "/redirect/*",
"redirect": "/index2.html"
},
{
"route": "/redirect/*/invalid",
"statusCode": 418
},
{
"route": "/*.google",
"redirect": "https://www.google.com/"
},
{
"route": "/*.{jpg}",
"redirect": "/jpg.html"
},
{
"route": "*.foo",
"redirect": "/foo.html"
},
{
"route": "/*.{png,gif}",
"redirect": "/png_gif.html"
},
{
"route": "/folder/*.{html,xml}",
"rewrite": "/folder/"
},
{
"route": "/rewrite_index2",
"rewrite": "/index2.html",
"headers": {
"a": "c",
"foo": "bar"
}
},
{
"route": "/rewrite-to-function",
"rewrite": "/api/headers"
},
{
"route": "/login-github",
"rewrite": "/.auth/login/github"
},
{
"route": "/logout",
"rewrite": "/.auth/logout"
},
{
"route": "/.auth/login/aad",
"statusCode": 404
},
{
"route": "/status-code-401.txt",
"statusCode": 401
},
{
"route": "/status-code-403.txt",
"statusCode": 403
},
{
"route": "/status-code-404.txt",
"statusCode": 404
},
{
"route": "/only-authenticated",
"allowedRoles": ["authenticated"]
},
{
"route": "/api/info",
"allowedRoles": ["authenticated"]
},
{
"route": "/api/error",
"statusCode": 403
}
],
"navigationFallback": {
"rewrite": "/index.html",
"exclude": ["*.{txt}"]
},
"responseOverrides": {
"401": {
"rewrite": "/custom-401.html"
},
"403": {
"rewrite": "/custom-403.html"
},
"404": {
"rewrite": "/custom-404.html"
}
},
"mimeTypes": {
".swaconfig": "application/json"
},
"globalHeaders": {
"a": "b"
}
}

Просмотреть файл

@ -1,12 +1,15 @@
{
"$schema": "../../../schema/swa-cli.config.schema.json",
"$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
"configurations": {
"static": {
"appLocation": "./",
"appLocation": "app",
"apiLocation": "api",
"outputLocation": "app",
"appBuildCommand": "npm run build --if-present",
"apiBuildCommand": "npm run build --if-present"
"outputLocation": ".",
"apiBuildCommand": "npm run build --if-present",
"port": 1234,
"host": "0.0.0.0",
"serverTimeout": 100,
"verbose": "silly"
}
}
}

Просмотреть файл

@ -1,5 +1,8 @@
/// <reference types="cypress" />
Cypress.Screenshot.defaults({
screenshotOnRunFailure: false,
});
Cypress.Cookies.defaults({
domain: "0.0.0.0",
});

Просмотреть файл

@ -1,5 +1,9 @@
/// <reference types="cypress" />
Cypress.Screenshot.defaults({
screenshotOnRunFailure: false,
});
const SWA_AUTH_COOKIE_NAME = "StaticWebAppsAuthCookie";
const clientPrincipal = {
identityProvider: "facebook",

Просмотреть файл

@ -1,5 +1,9 @@
/// <reference types="cypress" />
Cypress.Screenshot.defaults({
screenshotOnRunFailure: false,
});
context("Error pages", () => {
describe(`Custom 401 page`, () => {
it(`should respond with 401 status code`, () => {

Просмотреть файл

@ -1,5 +1,9 @@
/// <reference types="cypress" />
Cypress.Screenshot.defaults({
screenshotOnRunFailure: false,
});
context.only("/api", () => {
beforeEach(() => {
cy.visit("http://0.0.0.0:1234/");

Просмотреть файл

@ -1,5 +1,9 @@
/// <reference types="cypress" />
Cypress.Screenshot.defaults({
screenshotOnRunFailure: false,
});
context("Mime types", () => {
beforeEach(() => {
cy.visit("http://0.0.0.0:1234/");

Просмотреть файл

@ -1,5 +1,9 @@
/// <reference types="cypress" />
Cypress.Screenshot.defaults({
screenshotOnRunFailure: false,
});
context("route rules engine", { failOnStatusCode: false, defaultCommandTimeout: 20000 /* set this for Windows */ }, () => {
it("root returns /index.html", () => {
cy.visit("http://0.0.0.0:1234/").should(() => {

Просмотреть файл

@ -4,8 +4,8 @@
"description": "Azure Static Web Apps CLI",
"scripts": {
"test": "jest --detectOpenHandles --silent --verbose",
"e2e:start:static": "npm run build && node ./dist/cli/bin.js --config ./cypress/fixtures/static/swa-cli.config.json start app",
"e2e:start:blazor": "npm run build && node ./dist/cli/bin.js --config ./cypress/fixtures/blazor-starter/swa-cli.config.json start app",
"e2e:start:static": "npm run build && node ./dist/cli/bin.js --config ./cypress/fixtures/static/swa-cli.config.json start static",
"e2e:start:blazor": "npm run build && node ./dist/cli/bin.js --config ./cypress/fixtures/blazor-starter/swa-cli.config.json start blazor-starter",
"e2e:static": "start-server-and-test e2e:start:static http://0.0.0.0:1234 cy:run",
"e2e:blazor": "start-server-and-test e2e:start:blazor http://0.0.0.0:1234 cy:run",
"e2e:detection:prepare-samples": "npx -y degit sinedied/frameworks-playground#samples e2e/samples",

Просмотреть файл

@ -1,30 +0,0 @@
#!/usr/bin/env bash
# openssl genrsa -des3 -passout pass:x -out dev.pass.key 2048
# openssl rsa -passin pass:x -in dev.pass.key -out dev.key
# openssl req -new -key dev.key -out dev.csr
# openssl x509 -req -sha256 -days 365 -in dev.csr -signkey dev.key -out dev.crt
# openssl pkcs12 -export -out dev.pfx -inkey dev.key -in dev.crt
######################
# Become a Certificate Authority
######################
# Generate private key
# openssl genrsa -des3 -passout pass:x -out dev.key 2048
# # Generate root certificate
# openssl req -x509 -new -nodes -key dev.key -sha256 -days 825 -out dev.pem
# ######################
# # Create CA-signed certs
# ######################
# NAME=azurestaticweb.app
# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout dev.key -out dev.crt -config cert.conf -sha256
# cat dev.crt dev.key > dev.pem
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")