Skip to content
Closed

CI #2

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
2 changes: 2 additions & 0 deletions .config/csharpier/.csharpierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/*
!**/*.cs
3 changes: 3 additions & 0 deletions .config/csharpier/.csharpierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 120
}
30 changes: 30 additions & 0 deletions .config/cspell/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": "0.2",
"enableGlobDot": true,
"useGitignore": true,
"gitignoreRoot": ".",
"ignorePaths": ["LICENSE"],
"words": [
"CIFS",
"csharpierignore",
"csharpierrc",
"devcontainer",
"devcontainers",
"Finalizers",
"getgid",
"getuid",
"globalconfig",
"globaltool",
"ICMPV6",
"libc",
"msbuild",
"MSTEST",
"packagejson",
"reportgenerator",
"runas",
"runsettings",
"statvfs",
"Syscall",
"WINDIVERT"
]
}
3 changes: 3 additions & 0 deletions .config/dotnet/.globalconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dotnet_diagnostic.IDE0005.severity=warning
dotnet_diagnostic.CA1852.severity=warning
dotnet_diagnostic.CA2007.severity=warning
9 changes: 9 additions & 0 deletions .config/dotnet/Format.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<Target Name="DotNetFormatCheck" Condition="'$(DotNetFormatCheck)' == 'true'" AfterTargets="GetTargetPath">
<Exec Command="dotnet format style --verify-no-changes" WorkingDirectory="$(MSBuildProjectDirectory)" />
</Target>

<Target Name="DotNetFormat" Condition="'$(DotNetFormat)' == 'true'" AfterTargets="GetTargetPath">
<Exec Command="dotnet format style" WorkingDirectory="$(MSBuildProjectDirectory)" />
</Target>
</Project>
15 changes: 15 additions & 0 deletions .config/dotnet/Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Cake.Frosting" Version="5.1.0" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
<PackageVersion Include="LibGit2Sharp" Version="0.31.0" />
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.3.205" />
<PackageVersion Include="MinVer" Version="6.0.0" />
<PackageVersion Include="Mono.Posix" Version="7.1.0-final.1.21458.1" />
<PackageVersion Include="MSTest" Version="4.0.1" />
<PackageVersion Include="Native.WinDivert" Version="2.2.2" />
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions .config/dotnet/Project.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project>
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
<GlobalAnalyzerConfigFiles Include="$(MSBuildThisFileDirectory).globalconfig" />
</ItemGroup>

<Import Project="Format.targets" Condition="'$(MSBuildProjectExtension)' == '.csproj'" />

<PropertyGroup Condition="$(Configuration) == Release">
<Deterministic>true</Deterministic>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<DebugType>embedded</DebugType>
<EmbedAllSources>true</EmbedAllSources>
<PathMap>$(MSBuildProjectDirectory)=/_/$(MSBuildProjectName)</PathMap>
</PropertyGroup>
</Project>
16 changes: 16 additions & 0 deletions .config/dotnet/tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": 1,
"isRoot": true,
"tools": {
"csharpier": {
"version": "1.1.2",
"commands": ["csharpier"],
"rollForward": false
},
"dotnet-reportgenerator-globaltool": {
"version": "5.4.18",
"commands": ["reportgenerator"],
"rollForward": false
}
}
}
File renamed without changes.
9 changes: 9 additions & 0 deletions .config/git/ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.*
_*
!.devcontainer/
!**/.devcontainer/**
!.config/
!**/.config/**

node_modules/
!.github/
3 changes: 3 additions & 0 deletions .config/pnpm/rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lockfile=false
resolution-mode=time-based
store-dir=/home/dev/.local/share/pnpm/store
9 changes: 9 additions & 0 deletions .config/prettier/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 120,
"plugins": ["prettier-plugin-packagejson", "prettier-plugin-sh", "@prettier/plugin-xml", "prettier-plugin-ini"],
"xmlWhitespaceSensitivity": "ignore",
"overrides": [
{ "files": "app.manifest", "options": { "parser": "xml" } },
{ "files": "*.globalconfig", "options": { "parser": "ini" } }
]
}
9 changes: 9 additions & 0 deletions .config/workspaces/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<PropertyGroup>
<ArtifactsPath>$(MSBuildThisFileDirectory)artifacts</ArtifactsPath>
</PropertyGroup>

<ItemGroup>
<SourceRoot Include="$(MSBuildThisFileDirectory)" />
</ItemGroup>
</Project>
Empty file.
8 changes: 8 additions & 0 deletions .devcontainer/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
WORKSPACES=/workspaces
XDG_CONFIG_HOME=/home/dev/.config
XDG_CACHE_HOME=/home/dev/.cache
XDG_DATA_HOME=/home/dev/.local/share
XDG_STATE_HOME=/home/dev/.local/state
XDG_DATA_DIRS=/usr/local/share:/usr/share
XDG_CONFIG_DIRS=/etc/xdg
NUGET_PACKAGES=/home/dev/.local/share/NuGet/global-packages
6 changes: 6 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM mcr.microsoft.com/devcontainers/javascript-node:22

RUN apt-get update && apt-get install --yes \
cifs-utils

RUN npm install --global pnpm@latest-10
24 changes: 24 additions & 0 deletions .devcontainer/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
services:
devcontainer:
env_file:
- .env
- path: ../.local/.env
required: false
build:
context: .
dockerfile: Dockerfile
init: true
privileged: true
volumes:
- WORKSPACES:${WORKSPACES}
- ..:${WORKSPACES}/divert-windows
- XDG_CONFIG_HOME:${XDG_CONFIG_HOME}
- XDG_CACHE_HOME:${XDG_CACHE_HOME}
- XDG_DATA_HOME:${XDG_DATA_HOME}
- XDG_STATE_HOME:${XDG_STATE_HOME}
volumes:
WORKSPACES:
XDG_CONFIG_HOME:
XDG_CACHE_HOME:
XDG_DATA_HOME:
XDG_STATE_HOME:
41 changes: 41 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// spell-checker:ignore esbenp dotnettools
{
"name": "divert-windows",
"dockerComposeFile": "compose.yaml",
"service": "devcontainer",
"remoteUser": "dev",
"overrideCommand": true,
"workspaceFolder": "/workspaces/divert-windows",
"features": {
"ghcr.io/devcontainer-config/features/user-init:2": {},
"ghcr.io/devcontainer-config/features/dot-config:3": {},
"ghcr.io/devcontainers/features/dotnet:2": { "version": "8.0" }
},
"customizations": {
"vscode": {
"extensions": [
"esbenp.prettier-vscode",
"ms-azuretools.vscode-docker",
"streetsidesoftware.code-spell-checker",
"ms-dotnettools.csharp",
"csharpier.csharpier-vscode",
"github.vscode-github-actions"
],
"settings": {
"files.associations": {
"ignore": "ignore",
"attributes": "properties",
"rc": "properties",
"*.globalconfig": "ini",
"app.manifest": "xml"
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"cSpell.autoFormatConfigFile": true,
"cSpell.checkOnlyEnabledFileTypes": false,
"[csharp]": { "editor.defaultFormatter": "csharpier.csharpier-vscode" }
}
}
},
"onCreateCommand": "pnpm install && pnpm restore || true"
}
15 changes: 15 additions & 0 deletions .devcontainer/dot-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"git": { "attributes": "/home/dev/.config/git/attributes", "ignore": "/home/dev/.config/git/ignore" },
"pnpm": { "rc": "/home/dev/.config/pnpm/rc" },
"prettier": { ".prettierrc.json": ".prettierrc.json" },
"cspell": { "cspell.json": "cspell.json" },
"workspaces": {
"../git/attributes": ".gitattributes",
"../git/ignore": ".gitignore",
"../../package.json": "package.json",
"pnpm-workspace.yaml": "pnpm-workspace.yaml",
"Directory.Build.props": "Directory.Build.props"
},
"csharpier": { ".csharpierrc.json": ".csharpierrc.json", ".csharpierignore": ".csharpierignore" },
"dotnet": { "tools.json": ".config/dotnet-tools.json" }
}
95 changes: 95 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: "Main"

on:
pull_request:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
env:
GITHUB_REPOSITORY: ${{ github.repository }}
steps:
- name: Set lowercase repository name
run: echo "GITHUB_REPOSITORY=${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV

- name: Checkout
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Pre-build dev container image
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/${{ env.GITHUB_REPOSITORY }}/devcontainer
cacheFrom: ghcr.io/${{ env.GITHUB_REPOSITORY }}/devcontainer
push: always
runCmd: pnpm restore

- name: Lint
uses: devcontainers/[email protected]
with:
cacheFrom: ghcr.io/${{ env.GITHUB_REPOSITORY }}/devcontainer
push: never
runCmd: pnpm lint

- name: Build
uses: devcontainers/[email protected]
with:
cacheFrom: ghcr.io/${{ env.GITHUB_REPOSITORY }}/devcontainer
push: never
runCmd: pnpm build

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
.local/windows/Divert.Windows.TestRunner
.local/windows/Divert.Windows.Tests

test:
needs: build
runs-on: windows-latest
steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: .local/windows

- name: Run Tests
run: .local/windows/Divert.Windows.TestRunner/Divert.Windows.TestRunner.exe

- name: Upload Test Results
uses: actions/upload-artifact@v4
with:
name: test-coverage
path: .local/windows/TestResults/coverage.cobertura.xml

code-coverage:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download Test Results
uses: actions/download-artifact@v4
with:
name: test-coverage

- name: Codecov
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
files: coverage.cobertura.xml
token: ${{ secrets.CODECOV_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Publish"

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
env:
GITHUB_REPOSITORY: ${{ github.repository }}
steps:
- name: Set lowercase repository name
run: echo "GITHUB_REPOSITORY=${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV

- name: Checkout
uses: actions/checkout@v4

- name: Publish
uses: devcontainers/[email protected]
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
with:
imageName: ghcr.io/${{ env.GITHUB_REPOSITORY }}/devcontainer
cacheFrom: ghcr.io/${{ env.GITHUB_REPOSITORY }}/devcontainer
push: never
runCmd: pnpm run publish
5 changes: 0 additions & 5 deletions .gitignore

This file was deleted.

12 changes: 12 additions & 0 deletions Automation/Automation.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
<NoWarn>CA2007</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cake.Frosting" />
<PackageReference Include="LibGit2Sharp" />
<PackageReference Include="Mono.Posix" />
</ItemGroup>
</Project>
Loading