Skip to content
Open
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
46 changes: 46 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"extends": [
"@commitlint/config-conventional"
],
"rules": {
"type-enum": [
2,
"always",
[
"feat",
"fix",
"docs",
"style",
"refactor",
"test",
"chore",
"ci",
"perf",
"revert"
]
],
"type-case": [
2,
"always",
"lower-case"
],
"type-empty": [
2,
"never"
],
"subject-empty": [
2,
"never"
],
"subject-case": [
2,
"always",
"lower-case"
],
"header-max-length": [
2,
"always",
100
]
}
}
65 changes: 65 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Build artifacts
bin/
obj/
[Bb]in/
[Oo]bj/

# Visual Studio
.vs/
.vscode/
*.user
*.suo
*.userosscache
*.sln.docstates

# Test Results
TestResults/
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*.trx
*.coverage
*.coveragexml

# Benchmark Results
BenchmarkDotNet.Artifacts/

# NuGet
*.nupkg
*.snupkg
packages/
*.nuget.props
*.nuget.targets

# Git
.git/
.gitignore
.gitattributes

# Documentation
*.md
docs/

# CI/CD
.github/
.dockerignore

# Scripts
scripts/

# Logs
*.log
[Ll]og/
[Ll]ogs/

# OS files
.DS_Store
Thumbs.db

# IDE
*.swp
*.swo
*~

# Temporary files
*.tmp
*.temp
79 changes: 70 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,80 @@ on:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
build-and-test:
name: Build, Test & Quality Gates
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for commit validation

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

- name: Restore dependencies
run: dotnet restore

- name: Remove TicTacToe from solution (Linux only)
if: matrix.os == 'ubuntu-latest'
run: dotnet sln remove Projects/LunarDoggo.TicTacToe/LunarDoggo.TicTacToe.csproj

- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage"
- name: Lint
run: dotnet format --verify-no-changes
run: dotnet build --no-restore --configuration Release

- name: Type Check (Build with warnings as errors)
run: dotnet build --no-restore --configuration Release /p:TreatWarningsAsErrors=true

- name: Lint (Format verification)
run: dotnet format --verify-no-changes --no-restore

- name: Run Tests with Coverage
run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --results-directory ./TestResults /p:Threshold=80 /p:ThresholdType=line,branch

- name: Upload Coverage Report
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: ./TestResults/**/coverage.cobertura.xml
retention-days: 30

- name: Vulnerability Scan
run: dotnet list package --vulnerable --include-transitive
continue-on-error: false

- name: Verify Docker Build
if: matrix.os == 'ubuntu-latest'
run: docker build -t csharp-beginner-projects:ci .

commit-lint:
name: Validate Commit Messages
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install commitlint
run: |
npm install -g @commitlint/cli @commitlint/config-conventional

- name: Validate commit messages
run: |
npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

8 changes: 4 additions & 4 deletions Algorithms/Graphs/Pathfinding/BreadthFirstSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ namespace LunarDoggo.Algorithms.Graphs.Pathfinding
//In simple graphs |E| is bounded by O(|V|^2), so in such cases, one could use O(|V|^2) as the time complexity
public class BreadthFirstSearch
{
public void Run(IGraph<BFSVertex> graph, Vertex<BFSVertex> start)
public static void Run(IGraph<BFSVertex> graph, Vertex<BFSVertex> start)
{
if (graph is null)
{
throw new ArgumentNullException("The graph the DFS should be run on cannot be null");
throw new ArgumentNullException(nameof(graph), "The graph the BFS should be run on cannot be null");
}

this.Initialize(graph, start);
BreadthFirstSearch.Initialize(graph, start);

//BFS is usually implemented in a way that doesn't work on disconnected graphs. BFS can therefore be
//used to find all vertices contained in a connected component of the graph.
Expand All @@ -38,7 +38,7 @@ public void Run(IGraph<BFSVertex> graph, Vertex<BFSVertex> start)
}
}

private void Initialize(IGraph<BFSVertex> graph, Vertex<BFSVertex> start)
private static void Initialize(IGraph<BFSVertex> graph, Vertex<BFSVertex> start)
{
//Every vertex is initialized with the maximum possible distance to signify that the distance is invalid.
foreach (Vertex<BFSVertex> vertex in graph.Vertices)
Expand Down
6 changes: 3 additions & 3 deletions Algorithms/Graphs/Pathfinding/DepthFirstSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public void Run(IGraph<DFSVertex> graph)
{
if (graph is null)
{
throw new ArgumentNullException("The graph the DFS should be run on cannot be null");
throw new ArgumentNullException(nameof(graph), "The graph the DFS should be run on cannot be null");
}

this.Initialize(graph);
DepthFirstSearch.Initialize(graph);
//Current processing time
int time = 0;

Expand Down Expand Up @@ -55,7 +55,7 @@ private int RunRecursively(IGraph<DFSVertex> graph, Vertex<DFSVertex> start, int
return startTime;
}

private void Initialize(IGraph<DFSVertex> graph)
private static void Initialize(IGraph<DFSVertex> graph)
{
foreach (Vertex<DFSVertex> vertex in graph.Vertices)
{
Expand Down
53 changes: 53 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added
- Repository standards compliance implementation
- `.dockerignore` file for optimized Docker builds
- `docker-compose.yml` for local development environment
- Pre-commit hooks using Lefthook
- Commit message linting with Conventional Commits
- Code coverage threshold enforcement (80%)
- Enhanced CI pipeline with quality gates
- Vulnerability scanning in CI
- Comprehensive development scripts (`format.ps1`, `typecheck.ps1`, `coverage.ps1`)
- Documentation: `COMMIT_CONVENTION.md` and `CHANGELOG.md`

### Changed
- Enhanced `Directory.Build.props` with coverage settings and stricter analysis
- Updated test project with latest coverlet packages and threshold configuration
- Enhanced `scripts/test.ps1` to include coverage collection
- Improved README with comprehensive development workflow documentation

## [1.0.0] - Initial Release

### Added
- Example applications:
- Console input/output
- Console input validation
- File system access
- Simple Quiz Game
- WPF TicTacToe (Windows only)
- Data structures:
- LinkedList, ArrayList, Queue, Stack
- Graphs (directed and undirected)
- Algorithms:
- Sorting: InsertionSort
- Pathfinding: BFS, DFS
- Basic CI pipeline with build, test, and lint
- Unit test infrastructure with xUnit
- Code formatting with dotnet-format
- `.editorconfig` for consistent code style
- `Directory.Build.props` for shared project properties
- `global.json` for .NET SDK version specification
- Dockerfile for containerization
- Repository governance files: LICENSE, CODE_OF_CONDUCT.md, CONTRIBUTING.md

[Unreleased]: https://github.com/lunardoggo/CSharpBeginnerProjects/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/lunardoggo/CSharpBeginnerProjects/releases/tag/v1.0.0
Loading
Loading