Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/implement tests #3

Merged
merged 36 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d667796
Created initial test setup
adamthewilliam Oct 2, 2024
17af662
Implemented initial test and builders for microsoft teams
adamthewilliam Oct 2, 2024
7ac0b78
...
adamthewilliam Oct 2, 2024
ba71e36
...
adamthewilliam Oct 3, 2024
0edef8f
Implemented more tests, more refactoring and cleanup
adamthewilliam Oct 4, 2024
04394d5
Added some more comments
adamthewilliam Oct 4, 2024
c9b87c8
Implementing tests and refactoring
adamthewilliam Oct 4, 2024
b4f9e20
Moved some variables and secrets around in github config
adamthewilliam Oct 4, 2024
e0e4922
Refactored workflow by splitting unit tests and integration tests int…
adamthewilliam Oct 4, 2024
7d3a853
...
adamthewilliam Oct 4, 2024
11d8bc5
Implemented more tests
adamthewilliam Oct 4, 2024
c3c0acc
Implemented tests and more cleanup
adamthewilliam Oct 4, 2024
ae25293
Added env variables log
adamthewilliam Oct 4, 2024
e31a45a
Added environment for test
adamthewilliam Oct 5, 2024
5174ea3
...
adamthewilliam Oct 5, 2024
b0206b4
Implemented a resilient http client to retry and exponentially backof…
adamthewilliam Oct 5, 2024
f3581bb
Fixed warnings
adamthewilliam Oct 5, 2024
c5f3471
Made test case names consistent
adamthewilliam Oct 5, 2024
9c62759
...
adamthewilliam Oct 5, 2024
31c272e
Removed step to log environment variable values
adamthewilliam Oct 5, 2024
3a7f236
Cleanup
adamthewilliam Oct 5, 2024
0071538
...
adamthewilliam Oct 5, 2024
87a8bfd
Created maybe 70% of the required slack builders and created the unit…
adamthewilliam Oct 6, 2024
3e5f9a7
Implemented builds for slack
adamthewilliam Oct 6, 2024
3e5f408
Finished implementing integration tests for slack
adamthewilliam Oct 7, 2024
2320434
Made the result of read nullable
adamthewilliam Oct 7, 2024
5596ffa
Fixed possible null reference return and assignment warnings
adamthewilliam Oct 7, 2024
8e977b7
...
adamthewilliam Oct 7, 2024
59f0328
...
adamthewilliam Oct 7, 2024
a5bfa3f
...
adamthewilliam Oct 7, 2024
1555a2a
Cleanup and commenting
adamthewilliam Oct 7, 2024
c7022af
Updated docs
adamthewilliam Oct 7, 2024
f68a979
...
adamthewilliam Oct 7, 2024
b624507
...
adamthewilliam Oct 7, 2024
ff045e4
Updated structure of guides
adamthewilliam Oct 7, 2024
544b1f3
Updated Trusted By with cloudcat.dev
adamthewilliam Oct 7, 2024
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
29 changes: 19 additions & 10 deletions .github/workflows/pack-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ on:
pull_request:
branches: ["main"]

env:
SOLUTION_DIR: src/Hooki

jobs:
build-and-test:
environment: Test
runs-on: ubuntu-latest

steps:
Expand All @@ -21,13 +19,24 @@ jobs:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore ${{ env.SOLUTION_DIR }}
run: dotnet restore src/Hooki

- name: Build
run: dotnet build ${{ env.SOLUTION_DIR }} --configuration Release --no-restore
run: dotnet build src/Hooki --configuration Release --no-restore

- name: Run Unit Tests
run: dotnet test src/Hooki.UnitTests/Hooki.UnitTests.csproj --no-restore

- name: Test
run: dotnet test ${{ env.SOLUTION_DIR }} --no-restore
- name: Run Integration Tests
env:
DOTNET_ENVIRONMENT: ${{ vars.DOTNET_ENVIRONMENT }}
TEST_DISCORD_WEBHOOK_URL: ${{ secrets.TEST_DISCORD_WEBHOOK_URL }}
TEST_MICROSOFT_TEAMS_WEBHOOK_URL: ${{ secrets.TEST_MICROSOFT_TEAMS_WEBHOOK_URL }}
TEST_SLACK_WEBHOOK_URL: ${{ secrets.TEST_SLACK_WEBHOOK_URL }}
TEST_PIPEDREAM_URL: ${{ secrets.TEST_PIPEDREAM_URL }}
TEST_IMAGE_FILE_NAME: ${{ vars.TEST_IMAGE_FILE_NAME }}
TEST_IMAGE_CLOUD_URL: ${{ secrets.TEST_IMAGE_CLOUD_URL }}
run: dotnet test src/Hooki.IntegrationTests/Hooki.IntegrationTests.csproj --no-restore

pack-and-publish:
needs: build-and-test
Expand All @@ -42,10 +51,10 @@ jobs:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore ${{ env.SOLUTION_DIR }}
run: dotnet restore src/Hooki

- name: Build
run: dotnet build ${{ env.SOLUTION_DIR }} --configuration Release --no-restore
run: dotnet build src/Hooki --configuration Release --no-restore

- name: Set version and trim leading 'v'
run: |
Expand All @@ -54,7 +63,7 @@ jobs:
echo "Set VERSION to $version"

- name: Pack
run: dotnet pack ${{ env.SOLUTION_DIR }} --configuration Release --no-build -p:PackageVersion=${{env.VERSION}} --output ./nupkgs
run: dotnet pack src/Hooki/Hooki.csproj --configuration Release --no-build -p:PackageVersion=${{env.VERSION}} --output ./nupkgs

- name: Publish to NuGet
run: dotnet nuget push "./nupkgs/Hooki.*" --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- [About Hooki](#star2-about-the-project)
* [Features](#dart-features)
* [Why use Hooki?](#key-why-use-hooki)
- [Trusted By](#office-trusted-by)
- [Getting Started](#toolbox-getting-started)
* [Prerequisites](#bangbang-prerequisites)
- [Usage](#eyes-usage)
Expand Down Expand Up @@ -89,6 +90,23 @@ Hooki is a powerful .NET library designed to simplify the creation of webhook pa
- **Focus on Content:** Concentrate on your payload's data and style rather than low-level JSON structure.
- **Flexibility:** Easily extensible for custom webhook requirements while maintaining type safety.

## 🏢 Trusted By

<div align="center">
<table>
<tr>
<td align="center">
<a href="https://cloudcat.dev">
<img src="https://cloudcat.dev/img/logo.png" width="100px;" alt="Cloudcat Logo"/>
</a>
</td>
</tr>
<tr>
<td align="center">Cloudcat.dev</td>
</tr>
</table>
</div>

<!-- Getting Started -->
## 🧰 Getting Started

Expand All @@ -109,6 +127,10 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;

using Hooki.Discord.Enums;
using Hooki.Discord.Models.BuildingBlocks;
using Hooki.Discord.Models;

public class DiscordWebhookService
{
private readonly IHttpClientFactory _httpClientFactory;
Expand Down Expand Up @@ -201,10 +223,12 @@ public class ExampleController
## 🧭 Roadmap

* [x] POCOs
* [ ] Implement Unit Tests
* [x] Implement Unit Tests
* [x] Provide builders utilising fluent api to reduce boilerplate code when creating webhook payloads
* [ ] Support Files and Polls in Discord Webhook
* [ ] Implement type safety POCOs for Discord message components
* [ ] Introduce Validation to provide a better developer experience (Apps are not returning error details for 400s)
* [ ] Remove the use of objects in numerous places and replace with a clean union type solution for type safety and readability
* [ ] Provide builders utilising fluent api to reduce boilerplate code when creating webhook payloads
* [ ] Support other languages?

<!-- Contributing -->
Expand Down
57 changes: 56 additions & 1 deletion docs/examples/discord-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
![plot](../screenshots/discord-example-screenshot.png)

```csharp
using Hooki.Discord.Enums;
using Hooki.Discord.Models.BuildingBlocks;
using Hooki.Discord.Models;

return new DiscordWebhookPayload
{
Username = "Alertu Webhook",
Expand Down Expand Up @@ -35,4 +39,55 @@ return new DiscordWebhookPayload
}
}
};
```
```

![plot](../screenshots/discord-poll-example-screenshot.png)

```csharp
using Hooki.Discord.Models;
using Hooki.Discord.Models.BuildingBlocks;

var pollPayload = new DiscordWebhookPayload
{
Poll = new PollCreateRequest
{
Question = new PollMedia
{
Text = "What is your favorite TV show?",
},
Duration = 24,
AllowMultiSelect = true,
Answers = new List<PollAnswer>
{
new PollAnswer
{
AnswerId = 1,
PollMedia = new PollMedia
{
Text = "Penguin",
Emoji = new Emoji { Name = "🐧" }
}
},
new PollAnswer
{
AnswerId = 2,
PollMedia = new PollMedia
{
Text = "Game of Thrones",
Emoji = new Emoji { Name = "❄️" }
}
},
new PollAnswer
{
AnswerId = 3,
PollMedia = new PollMedia
{
Text = "Breaking Bad",
Emoji = new Emoji { Name = "🧪" }
}
}
}
}
};
```

4 changes: 4 additions & 0 deletions docs/examples/microsoft-teams-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
![plot](../screenshots/microsoft-teams-example-screenshot.png)

```csharp
using Hooki.MicrosoftTeams.Models;
using Hooki.MicrosoftTeams.Models.BuildingBlocks;
using Hooki.MicrosoftTeams.Models.Actions;

return new MessageCard
{
ThemeColor = "0x0EA5E9", // Light blue color
Expand Down
5 changes: 5 additions & 0 deletions docs/examples/slack-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
![plot](../screenshots/slack-example-screenshot.png)

```csharp
using Hooki.Slack.Models;
using Hooki.Slack.Models.BlockElements;
using Hooki.Slack.Models.Blocks;
using Hooki.Slack.Models.CompositionObjects;

return new SlackWebhookPayload
{
Blocks = new List<BlockBase>
Expand Down
Loading