Skip to content

Commit

Permalink
Merge branch 'master' into ludown
Browse files Browse the repository at this point in the history
  • Loading branch information
lei9444 committed Dec 10, 2019
2 parents 487e450 + 4180fed commit fb80662
Show file tree
Hide file tree
Showing 377 changed files with 9,205 additions and 3,918 deletions.
32 changes: 23 additions & 9 deletions .github/actions/conventional-pr/src/conventional-pr.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import * as core from '@actions/core';
import * as github from '@actions/github';

import { validateTitle, validateBody } from './utils';
import {
validateTitle,
validateBody,
validateBaseBranch,
PullRequestInfo,
isRelease,
} from './utils';

const OWNER = github.context.repo.owner;
const REPO = github.context.repo.repo;
Expand All @@ -22,6 +28,7 @@ const prQuery = `
pullRequest(number: $prNumber) {
title
body
baseRefName
}
}
}
Expand All @@ -43,22 +50,29 @@ async function run() {
repo: REPO,
prNumber,
});
const pr = repository.pullRequest;
const pr = repository?.pullRequest as PullRequestInfo;

if (!pr) {
core.setFailed('Not in a Pull Request context.');
return;
}

const titleErrors = validateTitle(pr.title);
const bodyErrors = validateBody(pr.body);
if (!isRelease(pr)) {
const titleErrors = validateTitle(pr.title);
const bodyErrors = validateBody(pr.body);
const branchErrors = validateBaseBranch(pr.title, pr.baseRefName);

if (titleErrors.length) {
core.setFailed(titleErrors.join('\n'));
}
if (titleErrors.length) {
core.setFailed(titleErrors.join('\n'));
}

if (bodyErrors.length) {
core.setFailed(bodyErrors.join('\n'));
if (bodyErrors.length) {
core.setFailed(bodyErrors.join('\n'));
}

if (branchErrors.length) {
core.setFailed(branchErrors.join('\n'));
}
}
} catch (err) {
core.error(err);
Expand Down
38 changes: 34 additions & 4 deletions .github/actions/conventional-pr/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import * as core from '@actions/core';

export interface PullRequestInfo {
title: string;
body: string;
baseRefName: string;
}
type ValidationResult = string[];

const validTypes = [
Expand All @@ -14,6 +19,7 @@ const validTypes = [
'ci',
'chore',
'revert',
'release',
];

const typeList = validTypes.map(t => ` - ${t}`).join('\n');
Expand All @@ -28,22 +34,46 @@ export function validateTitle(title: string): ValidationResult {
const hastype = validTypes.some(t => title.startsWith(`${t}: `));

if (!hastype) {
core.info(
`[Title] Missing type in title. Choose from the following:\n${typeList}`
errors.push(
`[Title] Must start with type (ex. 'feat: ').\nThe valid types are:\n${typeList}`
);
errors.push("[Title] Must start with type. i.e. 'feat: '");
}

return errors;
}

const refMatch = /(refs?|close(d|s)?|fix(ed|es)?) \#\d+/i;
const helpLink =
'https://help.github.com/en/github/managing-your-work-on-github/closing-issues-using-keywords';

export function validateBody(body: string): ValidationResult {
let errors: ValidationResult = [];

if (!refMatch.test(body)) {
errors.push('[Body] Must reference an issue.');
errors.push(
`[Body] Must reference an issue (ex. 'fixes #1234').\nSee ${helpLink} for more details.`
);
}

return errors;
}

export function isRelease(pr: PullRequestInfo) {
return pr.title.startsWith('release: ') && pr.baseRefName === 'stable';
}

export function validateBaseBranch(
title: string,
baseBranch: string
): ValidationResult {
let errors: ValidationResult = [];

if (title.startsWith('release: ') && baseBranch !== 'stable') {
errors.push("[Release] Release pull request must target 'stable' branch.");
} else if (baseBranch === 'stable') {
errors.push(
"[Branch] Pull requests cannot target 'stable' branch. Perhaps you meant to create a release or are targeting the wrong branch."
);
}

return errors;
Expand Down
38 changes: 26 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,12 @@ jobs:
- name: yarn test:coverage
run: yarn test:coverage
working-directory: Composer
# secrets are not exposed to PRs opened by forks, so just skip this step if it is not defined
- name: Publish coverage results
run: |
if [[ -z $COVERALLS_REPO_TOKEN ]]; then
echo "Coveralls token not found. Skipping."
else
cat coverage/lcov.info | ./node_modules/.bin/coveralls
fi
working-directory: Composer
env:
COVERALLS_SERVICE_NAME: "Github Actions"
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
- name: Coveralls
uses: coverallsapp/github-action@master
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./Composer/coverage/lcov.info

botproject:
name: BotProject
Expand All @@ -73,3 +67,23 @@ jobs:
- name: dotnet test
run: dotnet test
working-directory: BotProject/CSharp

docker-build:
name: Docker Build
timeout-minutes: 20
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1
- name: docker-compose build
run: docker-compose build
- name: Health check
run: |
docker-compose up -d
sleep 10
curl -Is http://localhost:3000 | grep -q "200 OK"
shell: bash
- name: Cleanup
if: always()
run: docker-compose down
4 changes: 1 addition & 3 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Pull Request Validation

on:
pull_request:
types: [opened, reopened, edited]
on: pull_request

jobs:
conventional-pr:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,7 @@ MyBots/*

# VsCode
Composer/.vscode/

# Docker App Data
.appdata
docker-compose.override.yml
41 changes: 37 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 9222,
"webRoot": "${workspaceFolder}"
},
{
"name": "LSP Server",
"type": "node",
"request": "launch",
"args": [
"${workspaceFolder}/Composer/packages/tools/language-servers/language-generation/demo/src/server.ts"
],
"runtimeArgs": [
"--nolazy",
"-r",
"${workspaceFolder}/Composer/node_modules/ts-node/register"
],
"sourceMaps": true,
"cwd": "${workspaceFolder}/Composer/packages/tools/language-servers/language-generation/demo/src",
"protocol": "inspector",
},
{
"type": "node",
"request": "launch",
"name": "Server: Launch",
"args": ["./build/server.js"],
"args": [
"./build/server.js"
],
"preLaunchTask": "server: build",
"restart": true,
"outFiles": ["./build/*"],
"outFiles": [
"./build/*"
],
"envFile": "${workspaceFolder}/Composer/packages/server/.env",
"outputCapture": "std",
"cwd": "${workspaceFolder}/Composer/packages/server"
Expand All @@ -20,8 +47,14 @@
"name": "Jest Debug",
"program": "${workspaceRoot}/Composer/node_modules/jest/bin/jest",
"stopOnEntry": false,
"args": ["--runInBand", "--env=jsdom", "--config=jest.config.js"],
"runtimeArgs": ["--inspect-brk"],
"args": [
"--runInBand",
"--env=jsdom",
"--config=jest.config.js"
],
"runtimeArgs": [
"--inspect-brk"
],
"cwd": "${workspaceRoot}/Composer/packages/server",
"sourceMaps": true,
"console": "integratedTerminal"
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{ "language": "typescript", "autoFix": true },
{ "language": "typescriptreact", "autoFix": true }
],
"eslint.workingDirectories": ["./Composer"],
"editor.formatOnSave": true,
"typescript.tsdk": "./Composer/node_modules/typescript/lib"
}
}
2 changes: 1 addition & 1 deletion BotProject/CSharp/ComposerDialogs/Main/Main.dialog
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"actions": [
{
"$type": "Microsoft.SendActivity",
"activity": "[bfdactivity-003038]"
"activity": "@{bfdactivity-003038()}"
}
]
}
Expand Down
1 change: 1 addition & 0 deletions BotProject/CSharp/Controllers/BotController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public BotController(BotManager botManager)
}

[HttpPost]
[HttpGet]
public async Task PostAsync()
{
// Delegate the processing of the HTTP POST to the adapter.
Expand Down
7 changes: 4 additions & 3 deletions BotProject/CSharp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-alpine AS build

WORKDIR /app/botproject/csharp
WORKDIR /src/botproject/csharp

COPY *.sln .
COPY *.csproj .
Expand All @@ -15,5 +15,6 @@ RUN dotnet publish -o out

FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-alpine AS runtime
WORKDIR /app/botproject/csharp
COPY --from=build /app/botproject/csharp/out .
CMD ["dotnet", "BotProject.dll"]
COPY --from=build /src/botproject/csharp/ComposerDialogs ./ComposerDialogs
COPY --from=build /src/botproject/csharp/out .
CMD ["dotnet", "BotProject.dll"]
1 change: 1 addition & 0 deletions BotProject/CSharp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)

app.UseDefaultFiles();
app.UseStaticFiles();
app.UseWebSockets();

//app.UseHttpsRedirection();
app.UseMvc();
Expand Down
1 change: 1 addition & 0 deletions BotProject/Templates/CSharp/Controllers/BotController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public BotController(IBotFrameworkHttpAdapter adapter, IBot bot)
}

[HttpPost]
[HttpGet]
public async Task PostAsync()
{
// Delegate the processing of the HTTP POST to the adapter.
Expand Down
1 change: 1 addition & 0 deletions BotProject/Templates/CSharp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)

app.UseDefaultFiles();
app.UseStaticFiles();
app.UseWebSockets();

//app.UseHttpsRedirection();
app.UseMvc();
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changelog

## Releases

### 11-20-2019

#### Added
* linting and validation UI (#1518) (@lei9444)

#### Changed
* improve build speed and bundle size (#1555) (@a-b-r-o-w-n)
* update `Conversation Started` trigger to `Greeting (Conversation Update)` (#1584) (@liweitian)

#### Fixed
* write QnA Maker endpointKey to settings (#1571) (@VanyLaw)
* fix docs typos (#1575) (@v-kydela)
* prevent double render in visual editor (#1601) (@yeze322)
* fix issue installing lubuild (#1606) (@lei9444)
* fix docker build (#1615) (@cwhitten)
5 changes: 4 additions & 1 deletion Composer/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
**/server/tmp.zip
# not ignore all lib folder because packages/lib, so probably we should rename that to libs
packages/lib/*/lib
packages/extensions/*/lib
packages/extensions/*/lib

Dockerfile
.dockerignore
2 changes: 1 addition & 1 deletion Composer/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = {
'eslint:recommended',
'plugin:prettier/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/eslint-recommended',
'prettier/@typescript-eslint',
'plugin:@bfc/bfcomposer/recommended',
Expand All @@ -27,6 +26,7 @@ module.exports = {
'@typescript-eslint/ban-ts-ignore': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-use-before-define': 'warn',

Expand Down
2 changes: 2 additions & 0 deletions Composer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ junit.xml
cypress/screenshots
cypress/results
cypress/videos

TestBots/
Loading

0 comments on commit fb80662

Please sign in to comment.