generated from JustArchiNET/ASF-PluginTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 3
121 lines (99 loc) · 3.45 KB
/
test_integration.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Integration Test
on:
push:
branches:
- main
- dev
schedule:
- cron: '55 22 */3 * *'
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_SDK_VERSION: 7.0.x
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
integration:
concurrency:
group: integration
if: github.actor == github.repository_owner
strategy:
max-parallel: 1 # only 1 else asf may crash due to parallel login using the same config file
matrix:
configuration: [Release]
asf_docker_tag: [latest, main, released]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
timeout-minutes: 5
with:
submodules: recursive
- name: Setup .NET Core
timeout-minutes: 5
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_SDK_VERSION }}
- name: Verify .NET Core
run: dotnet --info
- name: Build ${{ matrix.configuration }}
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 10
shell: pwsh
command: dotnet build -c "${{ matrix.configuration }}" -p:ContinuousIntegrationBuild=true -p:UseAppHost=false -p:isolate=true --nologo
- name: Populate config.zip
shell: python
run: |
import base64
data = rb'''${{ secrets.CONFIGZIP_B64 }}'''
with open('config.zip', 'wb') as f:
f.write(base64.b64decode(data))
- name: Extract config.zip
run: unzip config.zip
- name: Create plugin dir
run: |
mkdir -p plugins/ASFFreeGames
cp --archive -f ASFFreeGames/bin/${{ matrix.configuration }}/*/ASFFreeGames.* plugins/ASFFreeGames/
du -h plugins
- name: run docker
shell: python
timeout-minutes: 60
run: |
import subprocess
import sys
cmd = r"""docker run -e "ASF_CRYPTKEY=${{ secrets.ASF_CRYPTKEY }}" -v `pwd`/config:/app/config -v `pwd`/plugins:/app/plugins --name asf --pull always justarchi/archisteamfarm:${{ matrix.asf_docker_tag }}"""
with open('out.txt', 'ab+') as out, subprocess.Popen(cmd, shell=True, stdout=out, stderr=out) as process:
def flush_out() -> str:
out.flush()
out.seek(0)
output = out.read()
output = output.decode()
print(output)
return output
exit_code = None
try:
exit_code = process.wait(timeout=120)
except (TimeoutError, subprocess.TimeoutExpired):
print("Process reached timeout as expected")
process.kill()
exit_code = process.wait(timeout=10)
if exit_code is None:
process.terminate()
output = flush_out()
assert 'CollectGames() [FreeGames] found' in output, "unable to start docker with ASFFreeGames installed"
sys.exit(0)
print(f'Process stopped earlier than expected with {exit_code} code', file=sys.stderr)
flush_out()
if exit_code != 0:
sys.exit(exit_code)
sys.exit(111)
- name: Upload stdout
continue-on-error: true
if: always()
uses: actions/[email protected]
with:
name: ${{ matrix.configuration }}_${{ matrix.asf_docker_tag }}_stdout
path: out.txt