Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[repo] Switch to github actions for ci and remove TFMs for things which have gone out of support #38

Draft
wants to merge 16 commits into
base: develop
Choose a base branch
from
Draft
10 changes: 8 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# top-most EditorConfig file for Macross Software
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.{cs,js,config,xml,json,html,htm,aspx,asmx,ascx,css,token,xaml,sql,cshtml,ps1}]
indent_style = tab
tab_width = 4
trim_trailing_whitespace = true
indent_size = tab

# Dotnet code style settings:
Expand Down Expand Up @@ -183,4 +189,4 @@ dotnet_diagnostic.IDE0005.severity = warning
dotnet_diagnostic.CA1303.severity = none

[*.cshtml.cs]
dotnet_diagnostic.SA1649.severity = none
dotnet_diagnostic.SA1649.severity = none
78 changes: 78 additions & 0 deletions .github/workflows/Component.BuildTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Called by ci.yml to build & test project files
# See: https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow
name: Build Component

on:
workflow_call:
inputs:
project-name:
required: true
type: string
project-build-commands:
default: ''
required: false
type: string
code-cov-name:
required: true
type: string
code-cov-prefix:
default: 'unittests'
required: false
type: string
os-list:
default: '[ "windows-latest", "ubuntu-latest" ]'
required: false
type: string
tfm-list:
default: '[ "net462", "net6.0", "net6.0-windows" ]'
required: false
type: string

jobs:
build-test:

strategy:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix:
os: ${{ fromJSON(inputs.os-list) }}
version: ${{ fromJSON(inputs.tfm-list) }}
exclude:
- os: ubuntu-latest
version: net462
- os: ubuntu-latest
version: net6.0-windows

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Setup dotnet
uses: actions/setup-dotnet@v4

- name: dotnet restore ${{ inputs.project-name }}
run: dotnet restore ${{ inputs.project-name }} ${{ inputs.project-build-commands }}

- name: dotnet build ${{ inputs.project-name }}
run: dotnet build ${{ inputs.project-name }} --configuration Release --no-restore ${{ inputs.project-build-commands }}

- name: dotnet test ${{ inputs.project-name }}
run: dotnet test ${{ inputs.project-name }} --collect:"Code Coverage" --results-directory:TestResults --framework ${{ matrix.version }} --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" -- RunConfiguration.DisableAppDomain=true

- name: Install coverage tool
run: dotnet tool install -g dotnet-coverage

- name: Merging test results
run: dotnet-coverage merge -r -f cobertura -o ./TestResults/Cobertura.xml ./TestResults/*.coverage

- name: Upload code coverage ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }}
uses: codecov/[email protected]
continue-on-error: true # Note: Don't fail for upload failures
if: ${{ false }} # Note: Disabled for now
env:
OS: ${{ matrix.os }}
TFM: ${{ matrix.version }}
with:
file: TestResults/Cobertura.xml
env_vars: OS,TFM
flags: ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }}
name: Code Coverage for ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }} on [${{ matrix.os }}.${{ matrix.version }}]
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build

on:
pull_request:
branches: [ 'develop*', 'master*' ]

jobs:
lint-misspell-sanitycheck:
uses: ./.github/workflows/sanitycheck.yml

detect-changes:
runs-on: windows-latest
outputs:
changes: ${{ steps.changes.outputs.changes }}
steps:
- uses: AurorNZ/paths-filter@v3
id: changes
with:
filters: |
md: ['**.md']
build: ['build/**', '.github/**/*.yml', '**/*.targets', '**/*.props']
code: ['**.cs', '**.csproj', '.editorconfig']

lint-md:
needs: detect-changes
if: contains(needs.detect-changes.outputs.changes, 'md')
uses: ./.github/workflows/markdownlint.yml

lint-dotnet-format:
needs: detect-changes
if: contains(needs.detect-changes.outputs.changes, 'code')
uses: ./.github/workflows/dotnet-format.yml

build-test-solution:
needs: detect-changes
if: |
contains(needs.detect-changes.outputs.changes, 'code')
|| contains(needs.detect-changes.outputs.changes, 'build')
uses: ./.github/workflows/Component.BuildTest.yml
with:
project-name: 'Macross-Master.sln'
code-cov-name: 'Solution'

build-test:
needs: [
lint-misspell-sanitycheck,
detect-changes,
lint-md,
lint-dotnet-format,
build-test-solution,
]
if: always() && !cancelled() && !contains(needs.*.result, 'failure')
runs-on: windows-latest
steps:
- run: echo 'build complete'
23 changes: 23 additions & 0 deletions .github/workflows/dotnet-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Called by ci.yml to perform dotnet format linting
# See: https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow
name: Lint - dotnet format

on:
workflow_call:

jobs:
run-dotnet-format:
runs-on: windows-latest

steps:
- name: check out code
uses: actions/checkout@v4

- name: Setup dotnet
uses: actions/setup-dotnet@v4

- name: dotnet restore
run: dotnet restore

- name: dotnet format
run: dotnet format Macross-Master.sln --no-restore --verify-no-changes
20 changes: 20 additions & 0 deletions .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Called by ci.yml to perform markdown linting
# See: https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow
name: Lint - Markdown

on:
workflow_call:

jobs:
run-markdownlint:
runs-on: ubuntu-latest

steps:
- name: check out code
uses: actions/checkout@v4

- name: install markdownlint-cli
run: sudo npm install -g markdownlint-cli

- name: run markdownlint
run: markdownlint .
32 changes: 32 additions & 0 deletions .github/workflows/sanitycheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Called by ci.yml to perform general linting
# See: https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow
name: Lint - Spelling & Encoding

on:
workflow_call:

jobs:
run-misspell:
runs-on: ubuntu-latest

steps:
- name: check out code
uses: actions/checkout@v4

- name: install misspell
run: |
curl -L -o ./install-misspell.sh https://git.io/misspell
sh ./install-misspell.sh

- name: run misspell
run: ./bin/misspell -error .

run-sanitycheck:
runs-on: ubuntu-latest

steps:
- name: check out code
uses: actions/checkout@v4

- name: detect non-ASCII encoding and trailing space
run: python3 ./sanitycheck.py
55 changes: 0 additions & 55 deletions Build/Gated Build Pipeline.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
#if !NETSTANDARD2_0
using System.Diagnostics.CodeAnalysis;
#endif

namespace Macross.CommandLine
{
Expand Down Expand Up @@ -41,7 +43,7 @@
/// <returns>Whether or not the switch was specified.</returns>
public bool HasSwitch(string switchName)
{
if (string.IsNullOrEmpty(switchName))

Check warning on line 46 in ClassLibraries/Macross.CommandLine/Code/CommandLineArguments.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

'if' statement can be simplified

Check warning on line 46 in ClassLibraries/Macross.CommandLine/Code/CommandLineArguments.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

'if' statement can be simplified
throw new ArgumentNullException(nameof(switchName));

return Switches.Contains(switchName);
Expand All @@ -59,7 +61,7 @@
public bool TryGetOption(string optionName, [MaybeNullWhen(returnValue: false)] out string optionValue)
#endif
{
if (string.IsNullOrEmpty(optionName))

Check warning on line 64 in ClassLibraries/Macross.CommandLine/Code/CommandLineArguments.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

'if' statement can be simplified

Check warning on line 64 in ClassLibraries/Macross.CommandLine/Code/CommandLineArguments.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

'if' statement can be simplified
throw new ArgumentNullException(nameof(optionName));

return Options.TryGetValue(optionName, out optionValue);
Expand All @@ -82,7 +84,7 @@
/// <returns>The value that was specified for the given option.</returns>
public string GetOption(string optionName)
{
if (!TryGetOption(optionName, out string? OptionValue))

Check warning on line 87 in ClassLibraries/Macross.CommandLine/Code/CommandLineArguments.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

'if' statement can be simplified

Check warning on line 87 in ClassLibraries/Macross.CommandLine/Code/CommandLineArguments.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

'if' statement can be simplified
throw new KeyNotFoundException($"{optionName} was not specified. See help for more details.");
return OptionValue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Reflection;
using System.Runtime.InteropServices;

Expand All @@ -7,4 +7,4 @@

[assembly: Guid("c41cb00f-9086-4e76-936f-da915f971e51")]

[assembly: AssemblyVersion("0.0.1.20011")]
[assembly: AssemblyVersion("0.0.1.20011")]
10 changes: 7 additions & 3 deletions ClassLibraries/Macross.CommandLine/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Macross Software Command-Line

Macross.CommandLine is a simple and light-weight .NET Standard 2.0+ library for parsing the `string[]` command-line arguments passed into a process into a command with optional parameters, options, and switches.
Macross.CommandLine is a simple and light-weight .NET Standard 2.0+ library for
parsing the `string[]` command-line arguments passed into a process into a
command with optional parameters, options, and switches.

## Format

The parser supports the general format used by the `dotnet` command-line interface:
The parser supports the general format used by the `dotnet` command-line
interface:

`C:\application.exe command parameter1 parameter2 -option1 option1value -option2=option2value --option3 option3value -switch1`
`C:\application.exe command parameter1 parameter2 -option1 option1value
-option2=option2value --option3 option3value -switch1`
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;

using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>keypair.snk</AssemblyOriginatorKeyFile>
<Description>Macross Software command-line library tests.</Description>
Expand Down
Loading
Loading