-
Introduction
-
Requirements
-
Installation
-
Setup
HackerRank is a project designed with the intention to gamify the development process and create incentives for the developer through achievements and scoring systems.
.NET Core 5
.NET Tools
UltraHook
Ruby & RubyGems
Install .NET Core:
Download .NET (Linux, macOS, and Windows)
Install .NET Tools:
.NET tools - .NET CLI | Microsoft Docs
Install UltraHook:
UltraHook - Receive webhooks on localhost
Install Ruby:
Install RubyGems:
Clone the project
Create migrations for the main database:
VS:
add-migration Init -Context HackerRankContext
VS Code:
dotnet ef migrations add Init --context HackerRankContext
Update both databases:
VS:
update-database -Context HackerRankContext
update-database -Context HangFireContext
VS Code:
dotnet ef database update --context HackerRankContext
dotnet ef database update --context HangFireContext
Create access token from GitLab:
Go to edit profile -> access token
Create a new token with the following scopes: read_user, read_api, read_repository, read_registry
This will generate your AccessToken
Create an application in GitLab:
Go to edit profile -> applications
Create a new application with the following scopes: read_user, email, openid, profile
This will generate your ClientSecret and ClientId
These secret keys will be used in the next step
Add user secrets:
dotnet user-secrets init
Change each value for the corresponding values generated in the previous step
dotnet user-secrets set "Authentication-GitLab-ClientSecret" "ClientSecret"
dotnet user-secrets set "Authentication-GitLab-ClientId" "ClientId"
dotnet user-secrets set "Authentication-GitLab-APIKey" "AccessToken"
For both of these commands, use a password manager to generate a long random string of characters to use as the "SecretToken"
dotnet user-secrets set "Authentication-GitLab-WebHookAuthentication" "SecretTokenForActions"
dotnet user-secrets set "Authentication-GitLab-WebHookAuthenticationGroups" "SecretTokenForGroups"
Webhooks:
Go to settings -> webhooks, of the parent group
Create a new wehook with the following scopes: push events, coments, issue events, merge request events
The URL shoud follow the following structure: "https://localhost:YOUR_PORT_HERE/api/webhook/receive"
The secret should be the SecretTokenForActions from the previous step
Create yet another new wehook with the following scopes: member events and subgroup events
The URL shoud follow the following structure: "https://localhost:YOUR_PORT_HERE/api/webhook/receivegroups"
The secret should be the SecretTokenForGroups from the previous step
UltraHook:
Run this command after installing ultrahook and following the instructions to get an API key
ultrahook gitlab https://localhost:YOUR_PORT_HERE/api/webhook/receive
If for some reason ultrahook cannot read the API key stored on your device use this command instead
ultrahook gitlab -k API_KEY_HERE https://localhost:YOUR_PORT_HERE/api/webhook/receive
Copy the URL which ultrahook generates (should look something like this: username-gitlab.ultrahook.com)
Go to the project you want to track -> settings -> webhooks
Add the URL you copied in the previous step to the URL field
Add "SecretToken" you generated earlier to the secret token field
Check the following scopes: push events, comments, merge request events, issue events and then click "Add webhook"
SMTP:
In the EmailService class update the host, port and options of the smtp client connection to match the smtp client you are using. Papercut is a good free option which runs locally on your machine.
From your client of choice get both a ClientId and a ClientSecret and run the following commands:
dotnet user-secrets set "Authentication-MailTrap-ClientSecret" "ClientSecret"
dotnet user-secrets set "Authentication-MailTrap-ClientId" "ClientId"
That's it!