Skip to content

Commit 9004ce3

Browse files
committed
net8 -> net9. Add Unit Tests. Add Release workflows
1 parent 5efa3c8 commit 9004ce3

File tree

19 files changed

+954
-233
lines changed

19 files changed

+954
-233
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: 'Project Build'
2+
description: 'Builds RocketModFix projects'
3+
inputs:
4+
project_path:
5+
description: 'Path to project folder'
6+
required: true
7+
runtime_version:
8+
description: 'Build runtime version default linux-x64'
9+
required: false
10+
default: 'linux-x64'
11+
github_token:
12+
description: 'GitHub token'
13+
required: false
14+
outputs:
15+
version:
16+
description: "Generated version (SemVersion compatible)"
17+
value: ${{ steps.get-version.outputs.version }}
18+
is_prerelease:
19+
description: 'Gets if the version is a prerelease'
20+
value: ${{ steps.check-prerelease.outputs.is_prerelease }}
21+
runs:
22+
using: "composite"
23+
steps:
24+
# Generate semver compatible version from current tag and commit hash
25+
- name: Create version
26+
id: get-version
27+
run: echo "version=$(git describe --tags `git rev-list --tags --max-count=1`)+$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
28+
shell: bash
29+
30+
- name: Check Prerelease
31+
id: check-prerelease
32+
run: "if ${{ contains(steps.get-version.outputs.version, '-') }}; then
33+
echo is_prerelease=true >> $GITHUB_OUTPUT;
34+
else
35+
echo is_prerelease=false >> $GITHUB_OUTPUT;
36+
fi"
37+
shell: bash
38+
39+
# Commands that are used multiple times.
40+
# Placed in one place to make sure that the arguments would always be the same
41+
- name: Common commands
42+
id: common-commands
43+
run: |
44+
echo "dotnet-restore=dotnet restore \$PROJECT_PATH --runtime ${{ inputs.runtime_version }}" >> $GITHUB_OUTPUT
45+
echo "dotnet-build=dotnet build \$PROJECT_PATH --configuration Release --no-restore -p:RedistUpdateToolVersion=${{ steps.get-version.outputs.version }} --runtime ${{ inputs.runtime_version }}" >> $GITHUB_OUTPUT
46+
echo "dotnet-test=dotnet test \$PROJECT_PATH --configuration Release --no-restore --no-build --runtime ${{ inputs.runtime_version }}" >> $GITHUB_OUTPUT
47+
shell: bash
48+
49+
# Install dependencies (this needs to be a separate step from build for caching)
50+
- name: Install dependencies
51+
run: |
52+
${{ steps.common-commands.outputs.dotnet-restore }}
53+
pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$PROJECT_PATH" '${{ steps.common-commands.outputs.dotnet-restore }}'
54+
env:
55+
PROJECT_PATH: ${{ inputs.project_path }} # Used by commands in `common-commands` step
56+
shell: bash
57+
58+
# Build project
59+
- name: Build
60+
run: |
61+
${{ steps.common-commands.outputs.dotnet-build }}
62+
pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$PROJECT_PATH" '${{ steps.common-commands.outputs.dotnet-build }}'
63+
env:
64+
PROJECT_PATH: ${{ inputs.project_path }} # Used by commands in `common-commands` step
65+
shell: bash
66+
67+
# Test project
68+
- name: Test
69+
run: |
70+
pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$PROJECT_PATH" '${{ steps.common-commands.outputs.dotnet-test }}'
71+
env:
72+
PROJECT_PATH: ${{ inputs.project_path }} # Used by commands in `common-commands` step
73+
shell: bash
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Finds all tests projects for a project passed as the first argument
3+
# and runs a command passed as the second argument for every tests project found.
4+
# Also sets PROJECT_PATH environment variables with value of the tests project folder path.
5+
#
6+
# Example usage:
7+
# pwsh -f .github/actions/project-build/run-command-for-every-tests-project.ps1 "framework/OpenMod.Core" "echo \$PROJECT_PATH"
8+
#
9+
# Example output:
10+
# Tests project found: framework/OpenMod.Core/../tests/OpenMod.Core.Tests. Executing a command: echo $PROJECT_PATH
11+
# framework/OpenMod.Core/../tests/OpenMod.Core.Tests
12+
13+
$projectPath = $args[0]
14+
$projectName = Split-Path -Path $projectPath -Leaf
15+
$testsFolderPath = Join-Path -Path $projectPath -ChildPath "../tests"
16+
17+
$commandToExecute = $args[1]
18+
19+
Get-ChildItem -Path $testsFolderPath -Directory -Recurse `
20+
| Where-Object { $_.Name -match "^$projectName.*Tests$" } `
21+
| ForEach-Object {
22+
$testsProjectName = $_.Name
23+
$testsProjectPath = Join-Path -Path $testsFolderPath -ChildPath $testsProjectName
24+
Write-Output "Tests project found: $testsProjectPath. Executing a command: $commandToExecute"
25+
bash -c "PROJECT_PATH=$testsProjectPath && $commandToExecute"
26+
}

.github/workflows/RedistTool.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: RedistTool
2+
3+
on:
4+
create:
5+
tags:
6+
- "*"
7+
push:
8+
branches: [ master ]
9+
paths:
10+
- '.github/workflows/RedistTool.yaml'
11+
- 'src/**'
12+
- 'tests/**'
13+
pull_request:
14+
paths:
15+
- '.github/workflows/RedistTool.yaml'
16+
- 'src/**'
17+
- 'tests/**'
18+
19+
jobs:
20+
Build:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Setup .NET
30+
uses: actions/setup-dotnet@v4
31+
env:
32+
DOTNET_NOLOGO: true
33+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
34+
DOTNET_CLI_TELEMETRY_OPTOUT: true
35+
with:
36+
dotnet-version: 9.x
37+
38+
- name: Build UnturnedRedistUpdateTool
39+
uses: ./.github/actions/project-build
40+
id: auto-installer-build
41+
with:
42+
project_path: src/UnturnedRedistUpdateTool
43+
github_token: ${{ secrets.PAT }}
44+
45+
- name: Install zip
46+
run: sudo apt-get install zip
47+
48+
- name: Zip UnturnedRedistUpdateTool artifacts
49+
run: "cd ./src/UnturnedRedistUpdateTool/bin/Release/net9.0/linux-x64/UnturnedRedistUpdateTool && zip -qq -r ./UnturnedRedistUpdateTool.zip *"
50+
51+
- name: Upload UnturnedRedistUpdateTool
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: UnturnedRedistUpdateTool.zip
55+
path: "./src/UnturnedRedistUpdateTool/bin/Release/net9.0/linux-x64/UnturnedRedistUpdateTool/UnturnedRedistUpdateTool.zip"
56+
if-no-files-found: error
57+
58+
- name: Upload UnturnedRedistUpdateTool
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: UnturnedRedistUpdateTool.zip
62+
path: "./src/UnturnedRedistUpdateTool/bin/Release/net9.0/linux-x64/UnturnedRedistUpdateTool/UnturnedRedistUpdateTool.zip"
63+
if-no-files-found: error
64+
65+
- name: Create Release
66+
if: github.event_name == 'create' && github.event.ref_type == 'tag'
67+
uses: ncipollo/release-action@v1
68+
with:
69+
name: UnturnedRedistUpdateTool Release v${{ steps.auto-installer-build.outputs.version }}
70+
tag: ${{ steps.auto-installer-build.outputs.version }}
71+
artifacts: "./src/UnturnedRedistUpdateTool/bin/Release/net9.0/linux-x64/UnturnedRedistUpdateTool/UnturnedRedistUpdateTool.zip"
72+
token: ${{ secrets.PAT }}
73+
prerelease: ${{ steps.auto-installer-build.outputs.is_prerelease }}
74+
allowUpdates: true
75+
draft: true

UnturnedRedistUpdateTool.sln

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnturnedRedistUpdateTool", "src\UnturnedRedistUpdateTool\UnturnedRedistUpdateTool.csproj", "{1721A81C-A442-4E23-9CDE-0C1054951492}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0AB3BF05-4346-4AA6-1389-037BE0695223}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnturnedRedistUpdateTool.Tests", "tests\UnturnedRedistUpdateTool.Tests\UnturnedRedistUpdateTool.Tests.csproj", "{B83C339E-D272-4A06-8480-FD2C9F71C24C}"
13+
EndProject
14+
Global
15+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16+
Debug|Any CPU = Debug|Any CPU
17+
Debug|x64 = Debug|x64
18+
Debug|x86 = Debug|x86
19+
Release|Any CPU = Release|Any CPU
20+
Release|x64 = Release|x64
21+
Release|x86 = Release|x86
22+
EndGlobalSection
23+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
24+
{1721A81C-A442-4E23-9CDE-0C1054951492}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{1721A81C-A442-4E23-9CDE-0C1054951492}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{1721A81C-A442-4E23-9CDE-0C1054951492}.Debug|x64.ActiveCfg = Debug|Any CPU
27+
{1721A81C-A442-4E23-9CDE-0C1054951492}.Debug|x64.Build.0 = Debug|Any CPU
28+
{1721A81C-A442-4E23-9CDE-0C1054951492}.Debug|x86.ActiveCfg = Debug|Any CPU
29+
{1721A81C-A442-4E23-9CDE-0C1054951492}.Debug|x86.Build.0 = Debug|Any CPU
30+
{1721A81C-A442-4E23-9CDE-0C1054951492}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{1721A81C-A442-4E23-9CDE-0C1054951492}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{1721A81C-A442-4E23-9CDE-0C1054951492}.Release|x64.ActiveCfg = Release|Any CPU
33+
{1721A81C-A442-4E23-9CDE-0C1054951492}.Release|x64.Build.0 = Release|Any CPU
34+
{1721A81C-A442-4E23-9CDE-0C1054951492}.Release|x86.ActiveCfg = Release|Any CPU
35+
{1721A81C-A442-4E23-9CDE-0C1054951492}.Release|x86.Build.0 = Release|Any CPU
36+
{B83C339E-D272-4A06-8480-FD2C9F71C24C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37+
{B83C339E-D272-4A06-8480-FD2C9F71C24C}.Debug|Any CPU.Build.0 = Debug|Any CPU
38+
{B83C339E-D272-4A06-8480-FD2C9F71C24C}.Debug|x64.ActiveCfg = Debug|Any CPU
39+
{B83C339E-D272-4A06-8480-FD2C9F71C24C}.Debug|x64.Build.0 = Debug|Any CPU
40+
{B83C339E-D272-4A06-8480-FD2C9F71C24C}.Debug|x86.ActiveCfg = Debug|Any CPU
41+
{B83C339E-D272-4A06-8480-FD2C9F71C24C}.Debug|x86.Build.0 = Debug|Any CPU
42+
{B83C339E-D272-4A06-8480-FD2C9F71C24C}.Release|Any CPU.ActiveCfg = Release|Any CPU
43+
{B83C339E-D272-4A06-8480-FD2C9F71C24C}.Release|Any CPU.Build.0 = Release|Any CPU
44+
{B83C339E-D272-4A06-8480-FD2C9F71C24C}.Release|x64.ActiveCfg = Release|Any CPU
45+
{B83C339E-D272-4A06-8480-FD2C9F71C24C}.Release|x64.Build.0 = Release|Any CPU
46+
{B83C339E-D272-4A06-8480-FD2C9F71C24C}.Release|x86.ActiveCfg = Release|Any CPU
47+
{B83C339E-D272-4A06-8480-FD2C9F71C24C}.Release|x86.Build.0 = Release|Any CPU
48+
EndGlobalSection
49+
GlobalSection(SolutionProperties) = preSolution
50+
HideSolutionNode = FALSE
51+
EndGlobalSection
52+
GlobalSection(NestedProjects) = preSolution
53+
{1721A81C-A442-4E23-9CDE-0C1054951492} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
54+
{B83C339E-D272-4A06-8480-FD2C9F71C24C} = {0AB3BF05-4346-4AA6-1389-037BE0695223}
55+
EndGlobalSection
56+
EndGlobal

0 commit comments

Comments
 (0)