Skip to content

Commit 145d7b9

Browse files
authored
Update folder structure and add tests
* Refactor Notion calendar feed * refactor project structure * refactor and update structure * add release * Refine public API structure
1 parent 225f83e commit 145d7b9

37 files changed

Lines changed: 1075 additions & 348 deletions

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-test-pack:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Setup .NET
17+
uses: actions/setup-dotnet@v4
18+
with:
19+
dotnet-version: 10.0.x
20+
21+
- name: Restore
22+
run: dotnet restore Notion2Ical.sln
23+
24+
- name: Build
25+
run: dotnet build Notion2Ical.sln --configuration Release --no-restore
26+
27+
- name: Test
28+
run: dotnet test Notion2Ical.sln --configuration Release --no-build --verbosity normal
29+
30+
- name: Pack
31+
run: dotnet pack Notion2Ical/Notion2Ical.csproj --configuration Release --no-build --output artifacts
32+
33+
- name: Upload package artifact
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: nuget-package
37+
path: artifacts/*.nupkg

.github/workflows/release.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: "Package version, for example 0.1.0"
11+
required: true
12+
13+
permissions:
14+
contents: read
15+
id-token: write
16+
17+
jobs:
18+
publish:
19+
runs-on: ubuntu-latest
20+
environment: nuget
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup .NET
29+
uses: actions/setup-dotnet@v4
30+
with:
31+
dotnet-version: 10.0.x
32+
33+
- name: Verify release comes from main
34+
shell: bash
35+
run: |
36+
git fetch origin main
37+
git merge-base --is-ancestor "$GITHUB_SHA" origin/main
38+
39+
- name: Resolve version
40+
id: version
41+
shell: bash
42+
run: |
43+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
44+
echo "value=${{ inputs.version }}" >> "$GITHUB_OUTPUT"
45+
else
46+
echo "value=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
47+
fi
48+
49+
- name: Restore
50+
run: dotnet restore Notion2Ical.sln
51+
52+
- name: Build
53+
run: dotnet build Notion2Ical.sln --configuration Release --no-restore
54+
55+
- name: Test
56+
run: dotnet test Notion2Ical.sln --configuration Release --no-build --verbosity normal
57+
58+
- name: Pack
59+
run: dotnet pack Notion2Ical/Notion2Ical.csproj --configuration Release --no-build --output artifacts /p:PackageVersion=${{ steps.version.outputs.value }}
60+
61+
- name: NuGet login
62+
uses: NuGet/login@v1
63+
id: login
64+
with:
65+
user: ${{ vars.NUGET_USER }}
66+
67+
- name: Push to NuGet
68+
run: dotnet nuget push artifacts/*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
/obj
2-
/bin
1+
obj/
2+
bin/
3+
artifacts/
4+
.tokensave/

AGENTS.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
5+
This repository contains a .NET solution for exposing Notion tasks as an iCalendar feed.
6+
7+
- `Notion2Ical/`: main library targeting `net10.0`.
8+
- `Notion2Ical/NotionApi/`: DTOs that map responses from the Notion API.
9+
- `Notion2Ical/ICalendar/`: output models used to generate iCalendar data.
10+
- `Notion2Ical/Interfaces/`: public service and repository contracts.
11+
- `Notion2Ical.Tests/`: xUnit unit tests.
12+
- `.github/workflows/ci.yml`: CI workflow for restore, build, test, and NuGet packing.
13+
14+
## Build, Test, and Development Commands
15+
16+
Use .NET 10. If the local shell does not resolve it, run `source ~/.zshrc` first.
17+
18+
```bash
19+
dotnet restore Notion2Ical.sln
20+
dotnet build Notion2Ical.sln
21+
dotnet test Notion2Ical.sln
22+
dotnet pack Notion2Ical/Notion2Ical.csproj --configuration Release --output artifacts
23+
```
24+
25+
`dotnet test` runs the full unit test suite. `dotnet pack` creates a local NuGet package in `artifacts/`.
26+
27+
## Coding Style & Naming Conventions
28+
29+
Use modern C# style: file-scoped namespaces, nullable reference types, implicit usings, and project-level global usings. Keep local `using` directives out of source files unless a file-specific import is genuinely clearer.
30+
31+
Use PascalCase for public types and members. Keep DTOs in `NotionApi` and iCalendar output types in `ICalendar`; do not mix input and output models in the same namespace.
32+
33+
Prefer `System.Text.Json` over `Newtonsoft.Json`.
34+
35+
## Testing Guidelines
36+
37+
Tests use xUnit. Place tests in `Notion2Ical.Tests/` and name files after the unit under test, for example `NotionServiceTests.cs`.
38+
39+
Test names should describe behavior, e.g. `GetVCalendarData_SkipsTasksWithoutDueDate`. Avoid tests that call the real Notion API; use fakes or custom `HttpMessageHandler` implementations.
40+
41+
## Commit & Pull Request Guidelines
42+
43+
Follow the existing commit style: short, descriptive, imperative or present-tense messages, such as `Refactor Notion calendar feed`.
44+
45+
Pull requests should include a concise summary, test results, and any configuration or migration notes. Link related issues when applicable. For behavior changes, mention the affected feed output or Notion API assumptions.
46+
47+
## Security & Configuration Tips
48+
49+
Never commit Notion tokens, database IDs for private workspaces, or NuGet API keys. Use application configuration for `NotionCalendarOptions` and GitHub Secrets for future package publishing.
50+
51+
TokenSave may be available, but verify its worktree before relying on results.

Interfaces/INotionRepository.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

Interfaces/INotionService.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

Models/Name.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

Models/Properties.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

Models/QueryResponse.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

Models/Result.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)