Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build & Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 9.0.x
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: SS14.Labeller.Tests
run: dotnet test SS14.Labeller.Tests/SS14.Labeller.Tests.csproj -v n
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
/_ReSharper.Caches/
/.vs/**
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,45 @@ This app requires the `Pull request reviews`, `Pull requests` and `Issues` event

The token must have the `Issues` and `Pull requests` scopes enabled for read and write access.

## Testing and debug

You will need set up proxy for messages from github to your local machine. For that you can use https://smee.io
You can use 'Use the CLI' version of proxy:
1. Install smee cli using npm (if you dont have it - follow those instructions here https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
``` npm install --global smee-client ```
2. visit https://smee.io, click 'Start a new channel' and copy link that will be generated on top.
3. In console use smee cli to start proxy forwarding to your local machine```smee -u https://smee.io/{place-you-channel-code-here} -P //webhook```

Upon launching it will output line like
```
Forwarding https://smee.io/5999VPv39Kc69sxj to http://127.0.0.1:3000/webhooks
```
That means that every message it receives, including
* its payload
* its headers

will be proxied to http://127.0.0.1:3000/webhooks, so you need to configure your debug launch to use that port. To do that you can set launchSettings.json to following:
```
{
"profiles": {
"SS14.Labeller": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:3000"
}
}
}
```

Now we need set up repository. Create new repository or use existing one.
1. Go to 'Settings' tab of repository, then to 'Webhooks' (https://github.com/{owner}/{repository}/settings/hooks)
2. click 'Add webhook' option
3. Input url that smee.io gave your on previous step (should look like https://smee.io/5999VPv39Kc69sxj) into Payload URL
4. select content-type ```application/json```
5. Input secret word into Secret
6. In block 'which events would you like to trigger this webhook' select 'Let me select individual events' and check only event types you need to debug (currently supported are Issue/Pull Request/ Pull Request Review)
7. Set env variables GITHUB_WEBHOOK_SECRET using secret you passed in step 5, and GITHUB_TOKEN using PAT token for interaction (can be created in profile https://github.com/settings/personal-access-tokens)
Now you are all set up to try and create issure/ PR and get some events debugging!
27 changes: 27 additions & 0 deletions SS14.Labeller.Tests/CustomWebApplicationFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using NSubstitute;
using SS14.Labeller.GitHubApi;

namespace SS14.Labeller.Tests;

[ExcludeFromCodeCoverage]
public class CustomWebApplicationFactory : WebApplicationFactory<Program>
{
public IGitHubApiClient GitHubApiClient { get; private set; }

Check warning on line 14 in SS14.Labeller.Tests/CustomWebApplicationFactory.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'GitHubApiClient' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

/// <inheritdoc />
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
GitHubApiClient = Substitute.For<IGitHubApiClient>();

base.ConfigureWebHost(builder);
builder.ConfigureServices(sp =>
{
sp.Replace(new ServiceDescriptor(typeof(IGitHubApiClient), GitHubApiClient));
});
}
}
Loading