Skip to content

Commit

Permalink
update to dotnet 8 (#387)
Browse files Browse the repository at this point in the history
* update to dotnet 8

* upgrade github actions versions

* Update dependencies (#386)

* fixup readme

* improve and simplify ToString of inputs

* Fixed parser button repeat regex

* Spaces to tabs

* Spaces to tabs

* Should these be tabs too?

* Fix these files again

* Nobody cares about whitespace

---------

Co-authored-by: m4-used-rollout <[email protected]>
  • Loading branch information
Felk and m4-used-rollout authored Jan 29, 2024
1 parent 5214420 commit bba03b2
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 76 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@ jobs:

runs-on: ubuntu-latest

defaults:
run:
working-directory: TPP.Core

steps:
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- uses: actions/checkout@v2
- name: Publish the core
run: dotnet publish -c Release -r linux-x64 -p:PublishSingleFile=true --no-self-contained -p:IncludeNativeLibrariesForSelfExtract=true
run: dotnet publish TPP.Core -c Release -r linux-x64 -p:PublishSingleFile=true --no-self-contained -p:IncludeNativeLibrariesForSelfExtract=true
- name: Deploy the core to TPP
env:
SSHUSER: ${{ secrets.TPP_SSH_USER }}
Expand All @@ -28,5 +24,5 @@ jobs:
run: |
echo "$SSHPRIVKEY" > tpp.key
chmod 600 tpp.key
scp -q -i tpp.key -o StrictHostKeyChecking=no -P ${SSHPORT} bin/Release/net6.0/linux-x64/publish/TPP.Core ${SSHUSER}@${SSHHOST}:core_update
cat ../.github/workflows/deploy.sh | ssh -q -i tpp.key -o StrictHostKeyChecking=no -p ${SSHPORT} ${SSHUSER}@${SSHHOST}
scp -q -i tpp.key -o StrictHostKeyChecking=no -P ${SSHPORT} artifacts/publish/TPP.Core/release_linux-x64/TPP.Core ${SSHUSER}@${SSHHOST}:core_update
cat .github/workflows/deploy.sh | ssh -q -i tpp.key -o StrictHostKeyChecking=no -p ${SSHPORT} ${SSHUSER}@${SSHHOST}
14 changes: 7 additions & 7 deletions .github/workflows/inspect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- uses: actions/checkout@v2
- name: install resharper
run: dotnet tool install -g JetBrains.ReSharper.GlobalTools
- name: build solution before analysis
run: dotnet build
- name: determine changed files
uses: lots0logs/gh-action-get-changed-files@2.1.4
uses: lots0logs/gh-action-get-changed-files@2.2.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: run resharper
Expand All @@ -33,6 +33,6 @@ jobs:
jq --raw-output '.problems[] | "::\(.problem_class.severity) file=\(.file | gsub("\\\\";"/") | sub("\\$PROJECT_DIR\\$/";"")),line=\(.line),col=\(.offset)::\(.description)"' "$filename"
done
fi
- name: check code formatting
run: |
dotnet format --verify-no-changes --report=_format_report.json || python .github/workflows/process_format_report.py
# - name: check code formatting
# run: |
# dotnet format --verify-no-changes --report=_format_report.json || python .github/workflows/process_format_report.py
6 changes: 3 additions & 3 deletions .github/workflows/json-schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- uses: actions/checkout@v2
- name: Regenerate core config json schemas
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- uses: actions/checkout@v2
- name: Try publishing and running dummy mode
run: |
cd TPP.Core
dotnet run -- gendefaultconfig --outfile=config.json
dotnet publish -c Release
timeout --preserve-status -k1 3 dotnet ./bin/Release/net6.0/TPP.Core.dll start -m dummy || exit_code=$?
timeout --preserve-status -k1 3 dotnet ../artifacts/publish/TPP.Core/release/TPP.Core.dll start -m dummy || exit_code=$?
if [ $exit_code -ne 143 ]; then
echo "expected exit code 143, which means the program handled SIGTERM, but got $exit_code"
exit 1
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ jobs:
strategy:
matrix:
dotnet-sdk-version:
- 6.0.201 # currently running on stream
- 6.0.x
- 8.0.101 # currently running on stream
- 8.0.x

steps:
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-sdk-version }}
- uses: actions/checkout@v2
- name: MongoDB in GitHub Actions
uses: supercharge/mongodb-github-action@1.3.0
uses: supercharge/mongodb-github-action@1.10.0
with:
mongodb-version: 4.2.3
mongodb-replica-set: rs0
Expand Down
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseArtifactsOutput>true</UseArtifactsOutput>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ taken care of by the old python core.
Porting features over is an ongoing process.

## requirements
- .NET 6 SDK (exactly, not 7 or up), you can get one from [dotnet.microsoft.com](https://dotnet.microsoft.com/download)
- .NET 8 SDK (exactly, not 9 or up), you can get one from [dotnet.microsoft.com](https://dotnet.microsoft.com/download)
- If you use or run any components with persistence, MongoDB.
See [TPP.Persistence.MongoDB](TPP.Persistence.MongoDB) for details.

Expand Down
4 changes: 2 additions & 2 deletions TPP.Core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ and prevents the application from handling SIGTERM events on linux.

If you want faster startup times or graceful SIGTERM handling,
[publish](https://docs.microsoft.com/en-us/dotnet/core/deploying/) the project first.
For example, making a release build and running the resulting `dll` with the dotnet runtime may look like this:
For example, making a release build and running the resulting executable may look like this:
```
dotnet publish -c Release
dotnet ./bin/Release/net6.0/TPP.Core.dll --help
../artifacts/publish/TPP.Core/release/TPP.Core.exe --help
```
54 changes: 27 additions & 27 deletions TPP.Core/TPP.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="docopt.net" Version="0.8.1" />
<PackageReference Include="JsonNet.ContractResolvers" Version="2.0.0" />
<PackageReference Include="JsonSubTypes" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.15" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Discord.Lite" Version="0.2.0" />
<PackageReference Include="String.Similarity" Version="3.0.0" />
<PackageReference Include="TwitchLib.Api" Version="3.9.0" />
<!-- No release since 2022-3-11, but we want new features and this fix: https://github.com/TwitchLib/TwitchLib.Client/pull/170 -->
<PackageReference Include="TwitchLib.Client" Version="4.0.0-preview-d4d9679aaa93409ab2b31471d17673bb5e06504c" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="docopt.net" Version="0.8.1" />
<PackageReference Include="JsonNet.ContractResolvers" Version="2.0.0" />
<PackageReference Include="JsonSubTypes" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.15" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Discord.Lite" Version="0.2.0" />
<PackageReference Include="String.Similarity" Version="3.0.0" />
<PackageReference Include="TwitchLib.Api" Version="3.9.0" />
<!-- No release since 2022-3-11, but we want new features and this fix: https://github.com/TwitchLib/TwitchLib.Client/pull/170 -->
<PackageReference Include="TwitchLib.Client" Version="4.0.0-preview-d4d9679aaa93409ab2b31471d17673bb5e06504c" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\TPP.ArgsParsing\TPP.ArgsParsing.csproj" />
<ProjectReference Include="..\TPP.Inputting\TPP.Inputting.csproj" />
<ProjectReference Include="..\TPP.Match\TPP.Match.csproj" />
<ProjectReference Include="..\TPP.Persistence.MongoDB\TPP.Persistence.MongoDB.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TPP.ArgsParsing\TPP.ArgsParsing.csproj" />
<ProjectReference Include="..\TPP.Inputting\TPP.Inputting.csproj" />
<ProjectReference Include="..\TPP.Match\TPP.Match.csproj" />
<ProjectReference Include="..\TPP.Persistence.MongoDB\TPP.Persistence.MongoDB.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources/*" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources/*" />
</ItemGroup>

</Project>
27 changes: 17 additions & 10 deletions TPP.Core/config.runmode.schema.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"definitions": {
"InputConfig": {
"type": [
Expand All @@ -19,11 +19,17 @@
"n64",
"gc",
"switch",
"sgb",
"gbt",
"gbp",
"dualgb",
"dualnes",
"dualsnes",
"dualn64",
"dualgc"
"dualgc",
"dualsgb",
"dualgbt",
"dualgbp"
]
},
"FramesPerSecond": {
Expand Down Expand Up @@ -64,24 +70,25 @@
"type": "boolean"
},
"AllowHeldInputs": {
"description": "Overrides whether or not the input profile can use held inputs",
"type": "boolean"
},
"MaxSetLength": {
"description": "Overrides the input profile's max set length. Be careful: increasing a profile's max set length may enable soft resetting.",
"type": "integer"
},
"MaxSequenceLength": {
"description": "Overrides the input profile's max sequence length.",
"type": "integer"
},
"ControllerPrefix": {
"description": "Adds/overrides the input profile's first controller's prefix.",
"type": "string"
}
"type": [
"string",
"null"
]
},
"ControllerPrefix2": {
"description": "Adds/overrides the input profile's second controller's prefix.",
"type": "string"
"type": [
"string",
"null"
]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion TPP.Inputting/Inputs/AnalogInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public AnalogInput(
Strength = strength;
}

public override string ToString() => $"{DisplayedText}({ButtonName}={Strength})";
public override string ToInputString() => ButtonName + "=" + Strength;

#region polymorphic equals boilerplate

Expand Down
10 changes: 9 additions & 1 deletion TPP.Inputting/Inputs/Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ public Input(string displayedText, string buttonName, string originalText)
OriginalText = originalText;
}

public override string ToString() => $"{DisplayedText}({ButtonName})";
public virtual string ToInputString() => ButtonName;

public override string ToString()
{
string inputString = ToInputString();
return DisplayedText == inputString
? DisplayedText
: $"{DisplayedText}({inputString})";
}

#region polymorphic equals boilerplate

Expand Down
2 changes: 1 addition & 1 deletion TPP.Inputting/Inputs/TouchscreenDragInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public TouchscreenDragInput(
Y2 = y2;
}

public override string ToString() => $"{DisplayedText}({X},{Y}>{X2},{Y2})";
public override string ToInputString() => $"{X},{Y}>{X2},{Y2}";

#region polymorphic equals boilerplate

Expand Down
2 changes: 1 addition & 1 deletion TPP.Inputting/Inputs/TouchscreenInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public TouchscreenInput(
Y = y;
}

public override string ToString() => $"{DisplayedText}({X},{Y})";
public override string ToInputString() => X + "," + Y;

#region polymorphic equals boilerplate

Expand Down
4 changes: 2 additions & 2 deletions TPP.Inputting/Parsing/BareInputParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public BareInputParser(
{
inputSetRegex += @"(?<hold>-)?";
}
// repeat-group matches lazily '??' to not match any touchscreen coords coming afterwards for example
// repeat-group matches lazily '*?' to not match any touchscreen coords coming afterwards for example
string inputSequence = _maxSequenceLength > 1
? $@"^(?<inputset>{inputSetRegex}(?<repeat>[1-{_maxSequenceLength}])??){{1,{_maxSequenceLength}}}$"
? $@"^(?<inputset>{inputSetRegex}(?<repeat>[1-{_maxSequenceLength}])*?){{1,{_maxSequenceLength}}}$"
: $@"^(?<inputset>{inputSetRegex})$";
_regex = new Regex(inputSequence, RegexOptions.Compiled | RegexOptions.IgnoreCase);
}
Expand Down

0 comments on commit bba03b2

Please sign in to comment.