Skip to content
Merged
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
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
110 changes: 110 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Continuous Integration workflow.
#
# This workflow runs on every push and pull request to main branch:
# 1. Builds the solution using the reusable build workflow
# 2. Runs unit tests (no network required)
# 3. Runs integration tests against the live SMTP2GO API (requires secrets)
#
# Tests run against .NET 10 (primary target framework).
# Webhook delivery tests are excluded from CI because they require cloudflared.

name: CI

on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]

# Cancel in-progress runs when a new run is triggered for the same branch/PR.
# This prevents resource conflicts and saves CI minutes.
# Reference: https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# Restrict default permissions for security
permissions:
contents: read

jobs:
# Build the solution using the reusable workflow
build:
uses: ./.github/workflows/build.yml
with:
configuration: Debug
upload_artifacts: true

# Run unit tests (no secrets required)
unit-tests:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-output-Debug

- name: Restore execute permissions
# upload-artifact/download-artifact strips POSIX execute bits.
run: chmod +x ./tests/Smtp2Go.NET.UnitTests/bin/Debug/net10.0/Smtp2Go.NET.UnitTests

- name: Run unit tests
# xUnit v3 test projects are standalone executables — dotnet test does not discover them.
run: ./tests/Smtp2Go.NET.UnitTests/bin/Debug/net10.0/Smtp2Go.NET.UnitTests

# Run integration tests against the live SMTP2GO API.
# Webhook delivery tests are excluded because they require cloudflared (not available in CI).
# Sandbox and live API tests run with secrets configured as environment variables.
integration-tests:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
# Only run on push to main or when secrets are available (not on fork PRs).
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-output-Debug

- name: Restore execute permissions
# upload-artifact/download-artifact strips POSIX execute bits.
run: chmod +x ./tests/Smtp2Go.NET.IntegrationTests/bin/Debug/net10.0/Smtp2Go.NET.IntegrationTests

- name: Run integration tests (excluding webhook delivery)
# Exclude webhook delivery tests (require cloudflared + tunnel infrastructure).
# xUnit v3 uses -trait- (with trailing dash) to exclude tests by trait.
# This excludes tests with [Trait("Category", "Integration.Webhook")].
# Sandbox, live API, and webhook management tests all run.
run: ./tests/Smtp2Go.NET.IntegrationTests/bin/Debug/net10.0/Smtp2Go.NET.IntegrationTests -trait- "Category=Integration.Webhook"
env:
# SMTP2GO API keys and test addresses — configured as GitHub repository secrets.
# These map to the configuration keys used by TestConfiguration:
# Smtp2Go:ApiKey:Sandbox → Smtp2Go__ApiKey__Sandbox
# Smtp2Go:ApiKey:Live → Smtp2Go__ApiKey__Live
# Smtp2Go:TestSender → Smtp2Go__TestSender
# Smtp2Go:TestRecipient → Smtp2Go__TestRecipient
Smtp2Go__ApiKey__Sandbox: ${{ secrets.SMTP2GO_API_KEY_SANDBOX }}
Smtp2Go__ApiKey__Live: ${{ secrets.SMTP2GO_API_KEY_LIVE }}
Smtp2Go__TestSender: ${{ secrets.SMTP2GO_TEST_SENDER }}
Smtp2Go__TestRecipient: ${{ secrets.SMTP2GO_TEST_RECIPIENT }}
94 changes: 94 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Reusable workflow for building the solution.
#
# This workflow is designed to be called by other workflows to avoid
# redundant compilation. It builds the solution and uploads the build
# artifacts for downstream jobs to consume.
#
# Usage in other workflows:
# jobs:
# build:
# uses: ./.github/workflows/build.yml
# with:
# configuration: Release
#
# dependent-job:
# needs: build
# steps:
# - uses: actions/download-artifact@v4
# with:
# name: build-output-Release

name: Build

on:
# Allow this workflow to be called by other workflows
workflow_call:
inputs:
configuration:
description: 'Build configuration (Debug or Release)'
required: false
default: 'Debug'
type: string
upload_artifacts:
description: 'Whether to upload build artifacts'
required: false
default: true
type: boolean

# Also allow standalone execution for testing
workflow_dispatch:
inputs:
configuration:
description: 'Build configuration'
required: false
default: 'Debug'
type: choice
options:
- Debug
- Release

# Restrict default permissions for security
permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for version calculation

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x

- name: Restore dependencies
run: dotnet restore Smtp2Go.NET.slnx

- name: Build solution
# Build the entire solution with the specified configuration
run: dotnet build Smtp2Go.NET.slnx --configuration ${{ inputs.configuration }} --no-restore

- name: Upload build artifacts
# Upload the build output for downstream jobs to consume
# This avoids the need to rebuild in dependent workflows
if: ${{ inputs.upload_artifacts }}
uses: actions/upload-artifact@v4
with:
name: build-output-${{ inputs.configuration }}
path: |
src/**/bin/${{ inputs.configuration }}
src/**/obj/${{ inputs.configuration }}
tests/**/bin/${{ inputs.configuration }}
tests/**/obj/${{ inputs.configuration }}
samples/**/bin/${{ inputs.configuration }}
samples/**/obj/${{ inputs.configuration }}
retention-days: 1
Loading