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
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**/bin/
**/obj/
.git/
.github/
tests/
deploy/
*.md
src/z-logs/
src/Simulators/
src/docker-compose.yml
src/Dockerfile
60 changes: 60 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.{json,yml,yaml,props,csproj,slnx,xml}]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.cs]
# usings: System first, then alphabetical, outside the file-scoped namespace
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
csharp_using_directive_placement = outside_namespace:error
dotnet_diagnostic.IDE0005.severity = error
dotnet_diagnostic.IDE0065.severity = error

csharp_style_namespace_declarations = file_scoped:error
dotnet_diagnostic.IDE0161.severity = error

# house style: "this." on every field access, and only on fields
dotnet_style_qualification_for_field = true:error
dotnet_style_qualification_for_property = false
dotnet_style_qualification_for_method = false
dotnet_style_qualification_for_event = false
dotnet_diagnostic.IDE0009.severity = error

dotnet_style_readonly_field = true:error
dotnet_diagnostic.IDE0044.severity = error

csharp_prefer_braces = true:error
dotnet_diagnostic.IDE0011.severity = error

# private static readonly fields are PascalCase, like constants
dotnet_naming_rule.static_readonly_fields_pascal_case.severity = error
dotnet_naming_rule.static_readonly_fields_pascal_case.symbols = static_readonly_fields
dotnet_naming_rule.static_readonly_fields_pascal_case.style = pascal_case
dotnet_naming_symbols.static_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.static_readonly_fields.required_modifiers = static, readonly
dotnet_naming_style.pascal_case.capitalization = pascal_case

# private instance fields are camelCase without an underscore prefix
dotnet_naming_rule.private_fields_camel_case.severity = error
dotnet_naming_rule.private_fields_camel_case.symbols = private_fields
dotnet_naming_rule.private_fields_camel_case.style = camel_case
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
dotnet_naming_symbols.private_fields.required_modifiers = readonly
dotnet_naming_style.camel_case.capitalization = camel_case

[tests/**.cs]
# test names read as Method_Scenario_Expectation
dotnet_diagnostic.CA1707.severity = none
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto eol=lf
*.png binary
25 changes: 25 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: 2
updates:
# versions live in Directory.Packages.props; one grouped PR a week keeps the noise down
- package-ecosystem: nuget
directory: /
schedule:
interval: weekly
groups:
nuget:
patterns: ["*"]

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly

- package-ecosystem: docker
directory: /src
schedule:
interval: weekly

- package-ecosystem: docker-compose
directory: /src
schedule:
interval: weekly
98 changes: 98 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: CI

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

jobs:
build-and-test:
name: Build, format, unit + integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- uses: actions/setup-dotnet@v6
with:
global-json-file: global.json

- name: Restore
run: dotnet restore PaymentGatewayApi.slnx

# analyzers and warnings-as-errors come from Directory.Build.props
- name: Build
run: dotnet build PaymentGatewayApi.slnx --no-restore --configuration Release

- name: Check formatting
run: dotnet format PaymentGatewayApi.slnx --no-restore --verify-no-changes

- name: Check for vulnerable packages
run: |
dotnet list PaymentGatewayApi.slnx package --vulnerable --include-transitive | tee vulnerable.txt
if grep -q "has the following vulnerable packages" vulnerable.txt; then exit 1; fi

- name: Unit tests
run: >
dotnet test --project tests/PaymentGatewayApiUnitTests --no-build --configuration Release
--coverage --coverage-output-format cobertura --coverage-output unit.cobertura.xml
--coverage-settings coverage.settings.xml

# DynamoDB Local runs in a Testcontainers container, the runner's Docker is enough
- name: Integration tests
run: >
dotnet test --project tests/PaymentGatewayApiIntegrationTests --no-build --configuration Release
--coverage --coverage-output-format cobertura --coverage-output integration.cobertura.xml
--coverage-settings coverage.settings.xml

- name: Coverage report
if: ${{ !cancelled() }}
uses: danielpalme/ReportGenerator-GitHub-Action@5.5.11
with:
reports: tests/**/TestResults/*.cobertura.xml
targetdir: coverage
reporttypes: MarkdownSummaryGithub;Cobertura;HtmlInline

- name: Publish coverage summary
if: ${{ !cancelled() }}
run: cat coverage/SummaryGithub.md >> "$GITHUB_STEP_SUMMARY"

- uses: actions/upload-artifact@v7
if: ${{ !cancelled() }}
with:
name: coverage
path: coverage

end-to-end:
name: End-to-end tests against the compose stack
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- uses: actions/setup-dotnet@v6
with:
global-json-file: global.json

- name: Start DynamoDB Local, the bank simulator and the api container
working-directory: src
run: docker compose --profile api up --detach --build --wait

- name: End-to-end tests
run: dotnet test --project tests/PaymentGatewayApiEndToEndTests

- name: Stack logs
if: ${{ failure() }}
working-directory: src
run: docker compose --profile api logs
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ obj/

src/z-logs/*.log

deploy/aws/*
!deploy/aws/.gitkeep
TestResults/
Loading
Loading