initial creation of the sample and readme

This commit is contained in:
Brady Gaster 2018-10-31 15:50:50 -07:00
Родитель d0ce400380
Коммит 43c888e702
8 изменённых файлов: 87 добавлений и 21 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -44,6 +44,7 @@ dist/
global.json
BenchmarkDotNet.Artifacts/
korebuild-lock.txt
PullRequestR/android/.gradle/
!PullRequestR/function-dotnet/.vscode
!PullRequestR/function-javascript/.vscode
!PullRequestR/function-javascript/local.settings.json

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

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="android" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

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

@ -49,13 +49,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
@ -63,6 +56,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
@ -70,13 +70,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
@ -84,6 +77,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
@ -99,6 +99,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-main-apk-res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />

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

@ -30,7 +30,7 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String url = "https://YOUR-FUNCTION-URI.azurewebsites.net/api";
String url = "https://githubreceiverjavascript.azurewebsites.net/api";
PullRequestAdapter adapter = new PullRequestAdapter(this, pullRequests);
ListView lvItems = (ListView)findViewById(R.id.lvPullRequestList);

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

@ -2,6 +2,6 @@
"azureFunctions.projectRuntime": "~2",
"azureFunctions.projectLanguage": "C#",
"azureFunctions.templateFilter": "Verified",
"azureFunctions.deploySubpath": "function/bin/Release/netstandard2.0/publish",
"azureFunctions.deploySubpath": "bin/Release/netstandard2.0/publish",
"azureFunctions.preDeployTask": "publish"
}

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

@ -1,15 +1,21 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "echo",
"command": "echo ${workspaceFolder}",
},
{
"label": "clean",
"dependsOn": "echo",
"command": "dotnet clean",
"type": "shell",
"presentation": {
"reveal": "always"
},
"options": {
"cwd": "${workspaceFolder}/function"
"cwd": "${workspaceFolder}"
},
"problemMatcher": "$msCompile"
},
@ -23,7 +29,7 @@
"isDefault": true
},
"options": {
"cwd": "${workspaceFolder}/function"
"cwd": "${workspaceFolder}"
},
"presentation": {
"reveal": "always"
@ -38,7 +44,7 @@
"reveal": "always"
},
"options": {
"cwd": "${workspaceFolder}/function"
"cwd": "${workspaceFolder}"
},
"problemMatcher": "$msCompile"
},
@ -52,7 +58,7 @@
"reveal": "always"
},
"options": {
"cwd": "${workspaceFolder}/function"
"cwd": "${workspaceFolder}"
},
"problemMatcher": "$msCompile"
},
@ -62,7 +68,7 @@
"type": "shell",
"dependsOn": "build",
"options": {
"cwd": "${workspaceFolder}/function/bin/Debug/netstandard2.0"
"cwd": "${workspaceFolder}/bin/Debug/netstandard2.0"
},
"command": "func host start",
"isBackground": true,

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

@ -0,0 +1,39 @@
## Sample Setup
### Requirements
This setup process assumes you have the following tools installed:
1. [Visual Studio Code](https://code.visualstudio.com)
1. The [Azure Extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-node-azure-pack)
1. [JetBrains IntelliJ Idea](https://www.jetbrains.com/idea/) with the supporting prerequisites for developing Android applications in Java.
1. A [Microsoft Azure](https://azure.microsoft.com/en-us/free/) subscription. You can sign up for a free account [here](https://azure.microsoft.com/en-us/free/).
Note - you could also use Visual Studio 2017+ with the Azure workload installed to do these items, use [Android Studio](https://developer.android.com/studio/) for your client development, or any other setup you prefer.
### Setup Process
1. Create an Azure Resource group for the resources you'll create for the app.
1. Create a new Azure Function in the new resource group.
1. Create a new Azure SignalR Service instance in the same resource group (free tier is fine).
1. Set the `AzureSignalRConnectionString` environment variable in your Azure Function to be the connection string of the Azure SignalR Service you created.
1. Open the project workspace in this directory by typing `code .\project.code-workspace` at the command line.
1. Deploy **either** the `function-dotnet` code if you want a .NET back-end Function, or the `function-javascript` if you'd like to have a Node.js back-end function. Both sets of code operate the same way and will achieve the same result.
1. Change line 33 of `android\app\src\main\java\com.example.pullrequestr\MainActivity.java` from this:
```java
String url = "https://YOUR-FUNCTION-URI.azurewebsites.net/api";
```
to be the URL of your function, like this:
```java
String url = "https://MyGitHubReceiver.azurewebsites.net/api";
```
1. In the GitHub repository you wish to monitor, create a new WebHook and provide the URL of your function as the target URL, with the `pullrequests` suffix. Given the example URL above, the full target URL for your GitHub WebHook would be `https://MyGitHubReceiver.azurewebsites.net/pullrequests`.
1. Change the **Content type** of the request that will be sent to your Azure Function to `application/json`.
1. In the Function App settings blade of the Azure portal, copy the `default` host key and paste it into the **Secret** property for the GitHub WebHook.
1. Make sure to enable all pull request events so new pull request, closes, comments, and other activity will all be sent to your function.
1. Save the WebHook.
1. Run the Android app in the debugger.
1. Branch your repository (or fork it), make a change, and send pull request to your repository.