Skip to content

Commit 6c0bfad

Browse files
committed
Add environment-based control for Steam live tests and update workflows/tests accordingly
1 parent e4b3d0d commit 6c0bfad

6 files changed

Lines changed: 41 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ jobs:
1010

1111
test:
1212
uses: ./.github/workflows/test.yml
13+
with:
14+
steam-live-tests: true
1315

1416
pack:
1517
name: Pack

.github/workflows/test.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ name: Build & Test
22

33
on:
44
workflow_call:
5+
inputs:
6+
steam-live-tests:
7+
description: 'Run live Steam-network tests (sets STEAM_LIVE_TESTS=1).'
8+
type: boolean
9+
default: false
510
workflow_dispatch:
11+
inputs:
12+
steam-live-tests:
13+
description: 'Run live Steam-network tests (sets STEAM_LIVE_TESTS=1).'
14+
type: boolean
15+
default: false
616
push:
717
branches: [ develop ]
818
pull_request:
@@ -16,18 +26,19 @@ jobs:
1626
matrix:
1727
os: [windows-latest, ubuntu-latest]
1828
runs-on: ${{ matrix.os }}
19-
29+
2030
steps:
2131
- uses: actions/checkout@v6
2232
with:
2333
fetch-depth: 0
2434
- uses: actions/setup-dotnet@v5
2535
with:
2636
dotnet-version: '10.0.x'
27-
37+
2838
- name: Build & Test in Release Mode
2939
run: dotnet test --configuration Release --report-github
30-
# Ignore exit code 8 on Linux (zero tests are now allowed)
40+
# Ignore exit code 8 on Linux (zero tests are now allowed)
3141
# TODO: Remove this when linux is supported
3242
env:
33-
TESTINGPLATFORM_EXITCODE_IGNORE: ${{ matrix.os == 'ubuntu-latest' && '8' || '' }}
43+
TESTINGPLATFORM_EXITCODE_IGNORE: ${{ matrix.os == 'ubuntu-latest' && '8' || '' }}
44+
STEAM_LIVE_TESTS: ${{ inputs.steam-live-tests && '1' || '' }}

test/PG.StarWarsGame.Infrastructure.Test/GameServices/SteamWorkshopWebpageDownloaderTest.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ namespace PG.StarWarsGame.Infrastructure.Test.GameServices;
77

88
public class SteamWorkshopWebpageDownloaderTest
99
{
10-
[Fact]
10+
[Fact(
11+
Skip = TestEnvironment.SteamLiveTestsSkipReason,
12+
SkipUnless = nameof(TestEnvironment.SteamLiveTestsEnabled),
13+
SkipType = typeof(TestEnvironment))]
1114
public async Task GetSteamWorkshopsPageHtmlAsync()
1215
{
1316
var downloader = new SteamWorkshopWebpageDownloader();

test/PG.StarWarsGame.Infrastructure.Test/ModServices/DirectoryModNameResolverTest.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ public void Ctor_NullArgs_Throws()
3636
Assert.Throws<ArgumentNullException>(() => new OnlineModNameResolver(null!));
3737
}
3838

39-
[Theory]
39+
[Theory(
40+
Skip = TestEnvironment.SteamLiveTestsSkipReason,
41+
SkipUnless = nameof(TestEnvironment.SteamLiveTestsEnabled),
42+
SkipType = typeof(TestEnvironment))]
4043
[InlineData("path/1125718579", "z3r0x's mod version 3.5")]
4144
[InlineData("path/2978074984", "EAWFOC Mod Template")]
4245
public void ResolveName_Steam_WithoutModinfo_FindNameOnline(string path, string containsExpected)

test/PG.StarWarsGame.Infrastructure.Test/ModServices/OnlineModGameTypeResolverTest.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ public static IEnumerable<object[]> GetOnlineModsData()
2323
yield return ["2508288191", new[] {GameType.Foc, GameType.Eaw}, null!]; //Mod Template
2424
}
2525

26-
[Theory]
26+
[Theory(
27+
Skip = TestEnvironment.SteamLiveTestsSkipReason,
28+
SkipUnless = nameof(TestEnvironment.SteamLiveTestsEnabled),
29+
SkipType = typeof(TestEnvironment))]
2730
[MemberData(nameof(GetOnlineModsData))]
2831
public void Online_GetTagsFromSteamOnline(string knownId, ICollection<GameType> expectedTypes, GameType? incompatibleWith)
2932
{
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace PG.StarWarsGame.Infrastructure.Test;
4+
5+
public static class TestEnvironment
6+
{
7+
public const string SteamLiveTestsSkipReason =
8+
"Live Steam-network test. Set STEAM_LIVE_TESTS=1 to enable.";
9+
10+
public static bool SteamLiveTestsEnabled =>
11+
!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("STEAM_LIVE_TESTS"));
12+
}

0 commit comments

Comments
 (0)