Skip to content

Commit b57e241

Browse files
committed
Adds the function app setup
1 parent 50925cf commit b57e241

24 files changed

+6757
-0
lines changed

Diff for: .funcignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.js.map
2+
*.ts
3+
.git*
4+
.vscode
5+
local.settings.json
6+
test
7+
tsconfig.json

Diff for: .github/workflows/upload.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Linux_Node_Workflow_ScmCred
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@master
13+
- uses: actions/setup-node@v1
14+
with:
15+
node-version: '10.x'
16+
- name: 'run npm'
17+
run: |
18+
npm install
19+
npm run build --if-present
20+
npm run test --if-present
21+
- uses: Azure/functions-action@v1
22+
id: fa
23+
with:
24+
app-name: TypeScriptReposAutomation
25+
publish-profile: ${{ secrets.SCM_CREDENTIALS }}

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ typings/
5959

6060
# next.js build output
6161
.next
62+
dist

Diff for: .vscode/extensions.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"ms-azuretools.vscode-azurefunctions"
4+
]
5+
}

Diff for: .vscode/launch.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Attach to Node Functions",
6+
"type": "node",
7+
"request": "attach",
8+
"port": 9229,
9+
"preLaunchTask": "func: host start"
10+
}
11+
]
12+
}

Diff for: .vscode/settings.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"azureFunctions.deploySubpath": ".",
3+
"azureFunctions.projectLanguage": "TypeScript",
4+
"azureFunctions.projectRuntime": "~2",
5+
"debug.internalConsoleOptions": "neverOpen",
6+
"azureFunctions.preDeployTask": "npm prune"
7+
}

Diff for: .vscode/tasks.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "func",
6+
"command": "host start",
7+
"problemMatcher": "$func-watch",
8+
"isBackground": true,
9+
"dependsOn": "npm build"
10+
},
11+
{
12+
"type": "shell",
13+
"label": "npm build",
14+
"command": "npm run build",
15+
"dependsOn": "npm install",
16+
"problemMatcher": "$tsc"
17+
},
18+
{
19+
"type": "shell",
20+
"label": "npm install",
21+
"command": "npm install"
22+
},
23+
{
24+
"type": "shell",
25+
"label": "npm prune",
26+
"command": "npm prune --production",
27+
"dependsOn": "npm build",
28+
"problemMatcher": []
29+
}
30+
]
31+
}

Diff for: README.md

+43
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,46 @@
1+
### Meta
2+
3+
* __State:__ work in progress
4+
* __Dashboard:__ [Azure](https://portal.azure.com/#@72f988bf-86f1-41af-91ab-2d7cd011db47/resource/subscriptions/57bfeeed-c34a-4ffd-a06b-ccff27ac91b8/resourceGroups/typescriptreposautomatio/providers/Microsoft.Web/sites/TypeScriptReposAutomation)
5+
6+
### Setup
7+
8+
This repo represents a single Azure "Function App" - which is an app which hosts many functions.
9+
10+
```sh
11+
# Clone
12+
git clone https://github.com/microsoft/TypeScript-repos-automation.git repos-automation
13+
cd repos-automation
14+
npm install
15+
16+
# Validate
17+
npm test
18+
```
19+
20+
You can start the server by running
21+
22+
```sh
23+
npm start
24+
```
25+
26+
### Development
27+
28+
This repo depends on you having the [Azure Functions Core Tools](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local).
29+
Expect this install to take some time.
30+
31+
Windows users:
32+
33+
```sh
34+
npm install -g azure-functions-core-tools
35+
```
36+
37+
Mac users:
38+
39+
```sh
40+
brew tap azure/functions
41+
brew install azure-functions-core-tools
42+
```
43+
144

245
# Contributing
346

Diff for: TypeScriptRepoIssueWebhook/function.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"bindings": [
3+
{
4+
"authLevel": "function",
5+
"type": "httpTrigger",
6+
"direction": "in",
7+
"name": "req",
8+
"methods": [
9+
"get",
10+
"post"
11+
]
12+
},
13+
{
14+
"type": "http",
15+
"direction": "out",
16+
"name": "res"
17+
}
18+
],
19+
"scriptFile": "../dist/TypeScriptRepoIssueWebhook/index.js"
20+
}

Diff for: TypeScriptRepoIssueWebhook/index.ts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { AzureFunction, Context, HttpRequest } from "@azure/functions"
2+
// import * as isValid from "is-valid-github-event"
3+
import { numberOfThings } from "../shared/constants";
4+
5+
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
6+
context.log('HTTP trigger function processed a request.');
7+
8+
// TODO: security check
9+
// if (!isValid(req, 'my-secret', {event: 'issues', action: 'opened'})) {
10+
11+
// context.res = {
12+
// status: 400,
13+
// body: "Please pass a name on the query string or in the request body"
14+
// };
15+
// return;
16+
// }
17+
18+
19+
context.res = {
20+
body: "Hello there are " + numberOfThings + "things"
21+
};
22+
};
23+
24+
export default httpTrigger;

Diff for: TypeScriptRepoIssueWebhook/sample.dat

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "Azure"
3+
}

Diff for: ambient.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module "is-valid-github-event"

Diff for: fixtures/issues/created.json

+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
{
2+
"action": "opened",
3+
"issue": {
4+
"url": "https://api.github.com/repos/microsoft/TypeScript/issues/35451",
5+
"repository_url": "https://api.github.com/repos/microsoft/TypeScript",
6+
"labels_url": "https://api.github.com/repos/microsoft/TypeScript/issues/35451/labels{/name}",
7+
"comments_url": "https://api.github.com/repos/microsoft/TypeScript/issues/35451/comments",
8+
"events_url": "https://api.github.com/repos/microsoft/TypeScript/issues/35451/events",
9+
"html_url": "https://github.com/microsoft/TypeScript/issues/35451",
10+
"id": 531531204,
11+
"node_id": "MDU6SXNzdWU1MzE1MzEyMDQ=",
12+
"number": 35451,
13+
"title": "Explicit `this: this` annotation necessary to catch unbound class method errors with `--no-implicit-this`",
14+
"user": {
15+
"login": "Retsam",
16+
"id": 2281166,
17+
"node_id": "MDQ6VXNlcjIyODExNjY=",
18+
"avatar_url": "https://avatars0.githubusercontent.com/u/2281166?v=4",
19+
"gravatar_id": "",
20+
"url": "https://api.github.com/users/Retsam",
21+
"html_url": "https://github.com/Retsam",
22+
"followers_url": "https://api.github.com/users/Retsam/followers",
23+
"following_url": "https://api.github.com/users/Retsam/following{/other_user}",
24+
"gists_url": "https://api.github.com/users/Retsam/gists{/gist_id}",
25+
"starred_url": "https://api.github.com/users/Retsam/starred{/owner}{/repo}",
26+
"subscriptions_url": "https://api.github.com/users/Retsam/subscriptions",
27+
"organizations_url": "https://api.github.com/users/Retsam/orgs",
28+
"repos_url": "https://api.github.com/users/Retsam/repos",
29+
"events_url": "https://api.github.com/users/Retsam/events{/privacy}",
30+
"received_events_url": "https://api.github.com/users/Retsam/received_events",
31+
"type": "User",
32+
"site_admin": false
33+
},
34+
"labels": [
35+
36+
],
37+
"state": "open",
38+
"locked": false,
39+
"assignee": null,
40+
"assignees": [
41+
42+
],
43+
"milestone": null,
44+
"comments": 0,
45+
"created_at": "2019-12-02T20:51:16Z",
46+
"updated_at": "2019-12-02T20:51:16Z",
47+
"closed_at": null,
48+
"author_association": "NONE",
49+
"body": "**TypeScript Version:** 3.7.2\r\n\r\n<!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** `this` binding, `--no-implicit-this`, methods, `this: this`\r\n\r\n**Expected behavior:** The unbound `this` error is raised in both cases.\r\n\r\n**Actual behavior:** The compiler only catches the error in the case where the method was annotated as `this: this`.\r\n\r\n<!-- Did you find other bugs that looked similar? -->\r\n**Related Issues:** Found *many* `this` issues, couldn't find any related to the default inferred value in the absence of a `this` annotation on class methods. Sorry if I've just missed it.\r\n\r\n**Code**\r\n```ts\r\nclass Example1 {\r\n value = \"value\";\r\n method() {\r\n return this.value.toUpperCase();\r\n }\r\n}\r\n// Runtime-error, no compiler error\r\nnew Example1().method.call(null);\r\n\r\nclass Example2 {\r\n value = \"value\";\r\n method(this: this) {\r\n return this.value.toUpperCase();\r\n }\r\n}\r\n// Compiler error, as expected\r\nnew Example2().method.call(null);\r\n```\r\n\r\n\r\n\r\n<details><summary><b>Output<b></summary>\r\n\r\n```ts\r\n\"use strict\";\r\nclass Example1 {\r\n constructor() {\r\n this.value = \"value\";\r\n }\r\n method() {\r\n return this.value.toUpperCase();\r\n }\r\n}\r\n// Runtime-error, no compiler error\r\nnew Example1().method.call(null);\r\nclass Example2 {\r\n constructor() {\r\n this.value = \"value\";\r\n }\r\n method() {\r\n return this.value.toUpperCase();\r\n }\r\n}\r\n// Compiler error, as expected\r\nnew Example2().method.call(null);\r\n\r\n```\r\n\r\n\r\n</details>\r\n\r\n\r\n<details><summary><b>Compiler Options<b></summary>\r\n\r\n```json\r\n{\r\n \"compilerOptions\": {\r\n \"noImplicitAny\": true,\r\n \"strictNullChecks\": true,\r\n \"strictFunctionTypes\": true,\r\n \"strictPropertyInitialization\": true,\r\n \"strictBindCallApply\": true,\r\n \"noImplicitThis\": true,\r\n \"noImplicitReturns\": true,\r\n \"useDefineForClassFields\": false,\r\n \"alwaysStrict\": true,\r\n \"allowUnreachableCode\": false,\r\n \"allowUnusedLabels\": false,\r\n \"downlevelIteration\": false,\r\n \"noEmitHelpers\": false,\r\n \"noLib\": false,\r\n \"noStrictGenericChecks\": false,\r\n \"noUnusedLocals\": false,\r\n \"noUnusedParameters\": false,\r\n \"esModuleInterop\": true,\r\n \"preserveConstEnums\": false,\r\n \"removeComments\": false,\r\n \"skipLibCheck\": false,\r\n \"checkJs\": false,\r\n \"allowJs\": false,\r\n \"declaration\": true,\r\n \"experimentalDecorators\": false,\r\n \"emitDecoratorMetadata\": false,\r\n \"target\": \"ES2017\",\r\n \"module\": \"ESNext\"\r\n }\r\n}\r\n```\r\n\r\n\r\n</details>\r\n\r\n**Playground Link:** [Provided](https://www.typescriptlang.org/play/?ssl=4&ssc=1&pln=5&pc=1#code/MYGwhgzhAECiAeYC2AHEBTAjNA3gKGkOgDcwQBXdaAXmgCJSL06BuAopdAFwAsB7ACYAKAJS52RIgCdu5KQDtovAJYQAdI0pqufAKooU6KQGFI6UW0kBfPDYD0d6ACVy8rss4BaI1L5SANNDyfNDAfKjKGFLQPn548ugA7nCIqBiYomqcvIJqwGQgQvLkICAibHigkDAIyGjoAEzikppUtAxklKwS0Nn8wioQAFxKPKpi+JKSMlxyioManejaegZGphDm5T029o7G4SiRRjFSvgHQkDHwhsBc6ALxSSl1GA2Zfbn5pUUlZSxAA)\r\n \r\n--- \r\n\r\nGiven this behavior, [I've submitted a PR to typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/pull/1279) adding a linter rule that requires these annotations on all (non-arrow function) class methods that use `this`.\r\n\r\nHowever, I was wondering if there was a way this could be resolved on the Typescript compiler's side. The two code examples above seem semantically identical to me, and it's strange that they type-check differently. Is there a reason why it'd be harmful for `this: this` to be inferred from class methods that lack an explicit type annotation? \r\n\r\nNaturally, it would have to be behind a flag, but this is one of the few areas where I've hit runtime errors that the TS compiler hasn't caught. It's led to our codebase being somewhat paranoid about attaching methods to the prototype, preferring to define almost all methods as arrow function instance properties, which is a bit unfortunate from a memory perspective."
50+
},
51+
"repository": {
52+
"id": 20929025,
53+
"node_id": "MDEwOlJlcG9zaXRvcnkyMDkyOTAyNQ==",
54+
"name": "TypeScript",
55+
"full_name": "microsoft/TypeScript",
56+
"private": false,
57+
"owner": {
58+
"login": "microsoft",
59+
"id": 6154722,
60+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=",
61+
"avatar_url": "https://avatars2.githubusercontent.com/u/6154722?v=4",
62+
"gravatar_id": "",
63+
"url": "https://api.github.com/users/microsoft",
64+
"html_url": "https://github.com/microsoft",
65+
"followers_url": "https://api.github.com/users/microsoft/followers",
66+
"following_url": "https://api.github.com/users/microsoft/following{/other_user}",
67+
"gists_url": "https://api.github.com/users/microsoft/gists{/gist_id}",
68+
"starred_url": "https://api.github.com/users/microsoft/starred{/owner}{/repo}",
69+
"subscriptions_url": "https://api.github.com/users/microsoft/subscriptions",
70+
"organizations_url": "https://api.github.com/users/microsoft/orgs",
71+
"repos_url": "https://api.github.com/users/microsoft/repos",
72+
"events_url": "https://api.github.com/users/microsoft/events{/privacy}",
73+
"received_events_url": "https://api.github.com/users/microsoft/received_events",
74+
"type": "Organization",
75+
"site_admin": false
76+
},
77+
"html_url": "https://github.com/microsoft/TypeScript",
78+
"description": "TypeScript is a superset of JavaScript that compiles to clean JavaScript output.",
79+
"fork": false,
80+
"url": "https://api.github.com/repos/microsoft/TypeScript",
81+
"forks_url": "https://api.github.com/repos/microsoft/TypeScript/forks",
82+
"keys_url": "https://api.github.com/repos/microsoft/TypeScript/keys{/key_id}",
83+
"collaborators_url": "https://api.github.com/repos/microsoft/TypeScript/collaborators{/collaborator}",
84+
"teams_url": "https://api.github.com/repos/microsoft/TypeScript/teams",
85+
"hooks_url": "https://api.github.com/repos/microsoft/TypeScript/hooks",
86+
"issue_events_url": "https://api.github.com/repos/microsoft/TypeScript/issues/events{/number}",
87+
"events_url": "https://api.github.com/repos/microsoft/TypeScript/events",
88+
"assignees_url": "https://api.github.com/repos/microsoft/TypeScript/assignees{/user}",
89+
"branches_url": "https://api.github.com/repos/microsoft/TypeScript/branches{/branch}",
90+
"tags_url": "https://api.github.com/repos/microsoft/TypeScript/tags",
91+
"blobs_url": "https://api.github.com/repos/microsoft/TypeScript/git/blobs{/sha}",
92+
"git_tags_url": "https://api.github.com/repos/microsoft/TypeScript/git/tags{/sha}",
93+
"git_refs_url": "https://api.github.com/repos/microsoft/TypeScript/git/refs{/sha}",
94+
"trees_url": "https://api.github.com/repos/microsoft/TypeScript/git/trees{/sha}",
95+
"statuses_url": "https://api.github.com/repos/microsoft/TypeScript/statuses/{sha}",
96+
"languages_url": "https://api.github.com/repos/microsoft/TypeScript/languages",
97+
"stargazers_url": "https://api.github.com/repos/microsoft/TypeScript/stargazers",
98+
"contributors_url": "https://api.github.com/repos/microsoft/TypeScript/contributors",
99+
"subscribers_url": "https://api.github.com/repos/microsoft/TypeScript/subscribers",
100+
"subscription_url": "https://api.github.com/repos/microsoft/TypeScript/subscription",
101+
"commits_url": "https://api.github.com/repos/microsoft/TypeScript/commits{/sha}",
102+
"git_commits_url": "https://api.github.com/repos/microsoft/TypeScript/git/commits{/sha}",
103+
"comments_url": "https://api.github.com/repos/microsoft/TypeScript/comments{/number}",
104+
"issue_comment_url": "https://api.github.com/repos/microsoft/TypeScript/issues/comments{/number}",
105+
"contents_url": "https://api.github.com/repos/microsoft/TypeScript/contents/{+path}",
106+
"compare_url": "https://api.github.com/repos/microsoft/TypeScript/compare/{base}...{head}",
107+
"merges_url": "https://api.github.com/repos/microsoft/TypeScript/merges",
108+
"archive_url": "https://api.github.com/repos/microsoft/TypeScript/{archive_format}{/ref}",
109+
"downloads_url": "https://api.github.com/repos/microsoft/TypeScript/downloads",
110+
"issues_url": "https://api.github.com/repos/microsoft/TypeScript/issues{/number}",
111+
"pulls_url": "https://api.github.com/repos/microsoft/TypeScript/pulls{/number}",
112+
"milestones_url": "https://api.github.com/repos/microsoft/TypeScript/milestones{/number}",
113+
"notifications_url": "https://api.github.com/repos/microsoft/TypeScript/notifications{?since,all,participating}",
114+
"labels_url": "https://api.github.com/repos/microsoft/TypeScript/labels{/name}",
115+
"releases_url": "https://api.github.com/repos/microsoft/TypeScript/releases{/id}",
116+
"deployments_url": "https://api.github.com/repos/microsoft/TypeScript/deployments",
117+
"created_at": "2014-06-17T15:28:39Z",
118+
"updated_at": "2019-12-02T20:35:43Z",
119+
"pushed_at": "2019-12-02T20:46:21Z",
120+
"git_url": "git://github.com/microsoft/TypeScript.git",
121+
"ssh_url": "[email protected]:microsoft/TypeScript.git",
122+
"clone_url": "https://github.com/microsoft/TypeScript.git",
123+
"svn_url": "https://github.com/microsoft/TypeScript",
124+
"homepage": "https://www.typescriptlang.org",
125+
"size": 1194161,
126+
"stargazers_count": 56143,
127+
"watchers_count": 56143,
128+
"language": "TypeScript",
129+
"has_issues": true,
130+
"has_projects": true,
131+
"has_downloads": true,
132+
"has_wiki": true,
133+
"has_pages": false,
134+
"forks_count": 7644,
135+
"mirror_url": null,
136+
"archived": false,
137+
"disabled": false,
138+
"open_issues_count": 4099,
139+
"license": {
140+
"key": "apache-2.0",
141+
"name": "Apache License 2.0",
142+
"spdx_id": "Apache-2.0",
143+
"url": "https://api.github.com/licenses/apache-2.0",
144+
"node_id": "MDc6TGljZW5zZTI="
145+
},
146+
"forks": 7644,
147+
"open_issues": 4099,
148+
"watchers": 56143,
149+
"default_branch": "master"
150+
},
151+
"organization": {
152+
"login": "microsoft",
153+
"id": 6154722,
154+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=",
155+
"url": "https://api.github.com/orgs/microsoft",
156+
"repos_url": "https://api.github.com/orgs/microsoft/repos",
157+
"events_url": "https://api.github.com/orgs/microsoft/events",
158+
"hooks_url": "https://api.github.com/orgs/microsoft/hooks",
159+
"issues_url": "https://api.github.com/orgs/microsoft/issues",
160+
"members_url": "https://api.github.com/orgs/microsoft/members{/member}",
161+
"public_members_url": "https://api.github.com/orgs/microsoft/public_members{/member}",
162+
"avatar_url": "https://avatars2.githubusercontent.com/u/6154722?v=4",
163+
"description": "Open source, from Microsoft with love"
164+
},
165+
"sender": {
166+
"login": "Retsam",
167+
"id": 2281166,
168+
"node_id": "MDQ6VXNlcjIyODExNjY=",
169+
"avatar_url": "https://avatars0.githubusercontent.com/u/2281166?v=4",
170+
"gravatar_id": "",
171+
"url": "https://api.github.com/users/Retsam",
172+
"html_url": "https://github.com/Retsam",
173+
"followers_url": "https://api.github.com/users/Retsam/followers",
174+
"following_url": "https://api.github.com/users/Retsam/following{/other_user}",
175+
"gists_url": "https://api.github.com/users/Retsam/gists{/gist_id}",
176+
"starred_url": "https://api.github.com/users/Retsam/starred{/owner}{/repo}",
177+
"subscriptions_url": "https://api.github.com/users/Retsam/subscriptions",
178+
"organizations_url": "https://api.github.com/users/Retsam/orgs",
179+
"repos_url": "https://api.github.com/users/Retsam/repos",
180+
"events_url": "https://api.github.com/users/Retsam/events{/privacy}",
181+
"received_events_url": "https://api.github.com/users/Retsam/received_events",
182+
"type": "User",
183+
"site_admin": false
184+
}
185+
}

0 commit comments

Comments
 (0)