Skip to content

Commit edac901

Browse files
committed
Updated CI workflows and supporting scripts/tools.
1 parent 696a6c0 commit edac901

File tree

2 files changed

+84
-104
lines changed

2 files changed

+84
-104
lines changed

.github/workflows/Mochi.PhysX.yml

Lines changed: 33 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ env:
2121
ContinuousIntegrationBuild: true
2222
# This URL will be added to the restore sources if it isn't the official NuGet.org
2323
# (This is mainly intended to allow using the NuGet.org test servers to test CI in forks.)
24-
CiNuGetApiUrl: ${{secrets.NUGET_API_URL}}
24+
CiNuGetApiUrl: ${{vars.NUGET_API_URL}}
2525
jobs:
2626
# =====================================================================================================================================================================
2727
# Build PhysX
@@ -43,7 +43,7 @@ jobs:
4343
include:
4444
- rid: win-x64
4545
name: Windows x64
46-
os: windows-2019
46+
os: windows-2022
4747
build-command: ./build.cmd
4848
physx-install-path: external/PhysX/physx/install/Mochi.PhysX.Windows.x64
4949
physx-compiler-path: external/PhysX/physx/compiler/mochi-physx-win-x64
@@ -52,16 +52,15 @@ jobs:
5252
steps:
5353
# ----------------------------------------------------------------------- Checkout
5454
- name: Checkout
55-
uses: actions/checkout@v2
55+
uses: actions/checkout@v4
5656
with:
5757
submodules: recursive
5858

5959
# ----------------------------------------------------------------------- Setup Python
60-
- name: Setup Python 3.8
61-
if: matrix.platform.skip-tool-install != true
62-
uses: actions/setup-python@v2
60+
- name: Setup Python
61+
uses: actions/setup-python@v5
6362
with:
64-
python-version: '3.8'
63+
python-version: '3.11'
6564

6665
# ----------------------------------------------------------------------- Get PhysX revision
6766
- name: Get PhysX revision
@@ -71,7 +70,7 @@ jobs:
7170
# ----------------------------------------------------------------------- Build PhysX
7271
- name: Load cached PhysX build outputs
7372
id: cached-physx
74-
uses: actions/cache@v2
73+
uses: actions/cache@v4
7574
with:
7675
key: physx-${{matrix.rid}}-${{matrix.configuration.id}}-${{steps.physx.outputs.revision}}-${{hashFiles('build.*', 'tooling/*.cmd', 'tooling/*.sh', 'Mochi.PhysX.Modifications/**')}}
7776
path: physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar.gz
@@ -107,7 +106,7 @@ jobs:
107106
run: gzip physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar
108107

109108
- name: Upload PhysX build artifacts
110-
uses: actions/upload-artifact@v2
109+
uses: actions/upload-artifact@v4
111110
with:
112111
name: physx-${{matrix.rid}}
113112
path: physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar.gz
@@ -123,7 +122,7 @@ jobs:
123122
matrix:
124123
include:
125124
- name: Windows x64
126-
os: windows-2019
125+
os: windows-2022
127126
rid: win-x64
128127
build-command: ./build.cmd
129128
name: Mochi.PhysX ${{matrix.name}}
@@ -132,24 +131,30 @@ jobs:
132131
# ----------------------------------------------------------------------- Checkout
133132
- name: Checkout
134133
# We intentionally don't checkout submodules here, Mochi.PhysX.Generator should only use outputs from building PhysX
135-
uses: actions/checkout@v2
134+
uses: actions/checkout@v4
136135
#TODO: Actually we need them for Biohazrd still. Remove this once we switch to NuGet packages for it.
137136
with:
138137
submodules: recursive
139138

140139
# ----------------------------------------------------------------------- Setup .NET
141140
- name: Setup .NET
142141
if: matrix.platform.skip-tool-install != true
143-
uses: actions/setup-dotnet@v1
142+
uses: actions/setup-dotnet@v4
144143
with:
145-
# We need both the .NET 5 and .NET 6 SDKs because we currently use C# 10 while targeting .NET 5
144+
# We need both the .NET 5 and .NET 8 SDKs because we currently use C# 10 while targeting .NET 5
146145
dotnet-version: |
147-
5.0.x
148-
6.0.x
146+
5.x
147+
8.x
148+
149+
# ----------------------------------------------------------------------- Setup Python
150+
- name: Setup Python
151+
uses: actions/setup-python@v5
152+
with:
153+
python-version: '3.11'
149154

150155
# ----------------------------------------------------------------------- Download PhysX builds
151156
- name: Download PhysX ${{matrix.name}} builds
152-
uses: actions/download-artifact@v2
157+
uses: actions/download-artifact@v4
153158
with:
154159
name: physx-${{matrix.rid}}
155160

@@ -233,7 +238,7 @@ jobs:
233238
run: tar -cvzf Mochi.PhysX.Native-${{matrix.rid}}.tar.gz bin/Mochi.PhysX.Native
234239
- name: Upload native binaries
235240
if: always()
236-
uses: actions/upload-artifact@v2
241+
uses: actions/upload-artifact@v4
237242
with:
238243
name: Mochi.PhysX.Native-${{matrix.rid}}
239244
path: Mochi.PhysX.Native-${{matrix.rid}}.tar.gz
@@ -244,7 +249,7 @@ jobs:
244249
run: tar -cvzf Mochi.PhysX-packages-${{matrix.rid}}.tar.gz packages
245250
- name: Upload NuGet packages
246251
if: always()
247-
uses: actions/upload-artifact@v2
252+
uses: actions/upload-artifact@v4
248253
with:
249254
name: Packages
250255
if-no-files-found: error
@@ -256,7 +261,7 @@ jobs:
256261
run: tar -cvzf Mochi.PhysX-${{matrix.rid}}-generated.tar.gz Mochi.PhysX/#Generated Mochi.PhysX.Native/*.gen.*
257262
- name: Upload generated output
258263
if: always()
259-
uses: actions/upload-artifact@v2
264+
uses: actions/upload-artifact@v4
260265
with:
261266
name: Mochi.PhysX-${{matrix.rid}}-generated
262267
path: Mochi.PhysX-${{matrix.rid}}-generated.tar.gz
@@ -276,13 +281,13 @@ jobs:
276281
steps:
277282
# ----------------------------------------------------------------------- Setup .NET
278283
- name: Setup .NET
279-
uses: actions/setup-dotnet@v1
284+
uses: actions/setup-dotnet@v4
280285
with:
281-
dotnet-version: 6.0.x
286+
dotnet-version: 8.x
282287

283288
# ----------------------------------------------------------------------- Download built packages
284289
- name: Download built packages
285-
uses: actions/download-artifact@v2
290+
uses: actions/download-artifact@v4
286291
with:
287292
name: Packages
288293
- name: Extract built packages
@@ -310,21 +315,21 @@ jobs:
310315
steps:
311316
# ----------------------------------------------------------------------- Setup .NET
312317
- name: Setup .NET
313-
uses: actions/setup-dotnet@v1
318+
uses: actions/setup-dotnet@v4
314319
with:
315-
dotnet-version: 5.0.x
320+
dotnet-version: 8.x
316321

317322
# ----------------------------------------------------------------------- Download built packages
318323
- name: Download built packages
319-
uses: actions/download-artifact@v2
324+
uses: actions/download-artifact@v4
320325
with:
321326
name: Packages
322327
- name: Extract built packages
323328
run: for archive in Mochi.PhysX-packages-*.tar.gz; do tar --keep-old-files -xvf "$archive"; done
324329

325330
# ----------------------------------------------------------------------- Push to NuGet.org
326331
- name: Push to NuGet.org
327-
run: dotnet nuget push "packages/*.nupkg" --api-key ${{secrets.NUGET_API_KEY}} --source ${{secrets.NUGET_API_URL}}
332+
run: dotnet nuget push "packages/*.nupkg" --api-key ${{secrets.NUGET_API_KEY}} --source ${{vars.NUGET_API_URL}}
328333
env:
329334
# This is a workaround for https://github.com/NuGet/Home/issues/9775
330335
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0
@@ -340,74 +345,8 @@ jobs:
340345
steps:
341346
# ----------------------------------------------------------------------- Download all artifacts
342347
- name: Download artifacts
343-
uses: actions/download-artifact@v2
348+
uses: actions/download-artifact@v4
344349

345350
# ----------------------------------------------------------------------- Upload release assets
346351
- name: Upload release assets
347-
uses: actions/github-script@v4
348-
with:
349-
user-agent: actions/github-script for ${{github.repository}}
350-
script: |
351-
const fs = require('fs').promises;
352-
const path = require('path');
353-
const uploadUrl = context.payload.release.upload_url;
354-
355-
if (!uploadUrl) {
356-
throw "Missing release asset upload URL!";
357-
}
358-
359-
async function uploadAssets(directoryPath) {
360-
for (let filePath of await fs.readdir(directoryPath)) {
361-
filePath = path.join(directoryPath, filePath);
362-
const stats = await fs.stat(filePath);
363-
364-
if (stats.isDirectory()) {
365-
console.log(`Entering '${filePath}'`);
366-
await uploadAssets(filePath);
367-
continue;
368-
}
369-
370-
console.log(`Uploading '${filePath}'`);
371-
await github.repos.uploadReleaseAsset({
372-
url: uploadUrl,
373-
headers: {
374-
'content-type': 'application/octet-stream',
375-
'content-length': stats.size
376-
},
377-
name: path.basename(filePath),
378-
data: await fs.readFile(filePath)
379-
});
380-
}
381-
}
382-
383-
await uploadAssets('.');
384-
385-
# =====================================================================================================================================================================
386-
# Send CI Failure Notification
387-
# =====================================================================================================================================================================
388-
send-ci-failure-notification:
389-
name: Send CI Failure Notification
390-
needs: [build-physx, build-mochi-physx, publish-packages-github, publish-packages-nuget-org, publish-release-assets]
391-
if: failure() && github.event_name != 'pull_request'
392-
continue-on-error: true
393-
runs-on: ubuntu-latest
394-
steps:
395-
# ----------------------------------------------------------------------- Checkout
396-
- name: Checkout
397-
uses: actions/checkout@v2
398-
399-
# ----------------------------------------------------------------------- Setup Python
400-
- name: Setup Python 3.8
401-
uses: actions/setup-python@v2
402-
with:
403-
python-version: '3.8'
404-
405-
# ----------------------------------------------------------------------- Send CI Failure Notification
406-
- name: Send Notification
407-
run: python .github/workflows/send-ci-failure-notification.py
408-
env:
409-
webhook_url: ${{secrets.TEAMS_WEBHOOK_URL}}
410-
github_organization: ${{github.repository_owner}}
411-
github_repo: ${{github.repository}}
412-
github_workflow_name: ${{github.workflow}}
413-
github_run_number: ${{github.run_id}}
352+
run: gh release upload ${{github.event.release.tag_name}} **/* --clobber

.github/workflows/gha.py

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#!/usr/bin/env python3
12
# GitHub Actions Utility Functions
23
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions
4+
import io
35
import os
46
import sys
57

@@ -13,15 +15,16 @@ def fail_if_errors():
1315
def print_error(message):
1416
global errors_were_printed
1517
errors_were_printed = True
16-
print(f"::error::{message}", file=sys.stderr)
18+
print(f"::error::{message}")
1719

1820
def print_warning(message):
19-
print(f"::warning::{message}", file=sys.stderr)
21+
print(f"::warning::{message}")
2022

21-
def set_output(name, value):
22-
if isinstance(value, bool):
23-
value = "true" if value else "false"
24-
print(f"::set-output name={name}::{value}")
23+
def print_notice(message):
24+
print(f"::notice::{message}")
25+
26+
def print_debug(message):
27+
print(f"::debug::{message}")
2528

2629
def github_file_command(command, message):
2730
command = f"GITHUB_{command}"
@@ -34,17 +37,51 @@ def github_file_command(command, message):
3437
if not os.path.exists(command_file):
3538
print_error(f"'{command}' points to non-existent file '{command_file}')")
3639
sys.exit(1)
37-
40+
3841
with open(command_file, 'a') as command_file_handle:
3942
command_file_handle.write(message)
4043
command_file_handle.write('\n')
4144

45+
def set_output(name, value):
46+
if isinstance(value, bool):
47+
value = "true" if value else "false"
48+
github_file_command("OUTPUT", f"{name}<<GHA_PY_EOF\n{value}\nGHA_PY_EOF")
49+
4250
def set_environment_variable(name, value):
4351
github_file_command("ENV", f"{name}={value}")
4452

4553
def add_path(path):
4654
github_file_command("PATH", path)
4755

56+
class JobSummary:
57+
def __init__(self):
58+
self.file: io.TextIOBase | None = None
59+
60+
summary_file_path_var = "GITHUB_STEP_SUMMARY"
61+
summary_file_path = os.getenv(summary_file_path_var)
62+
if summary_file_path is None:
63+
print_warning(f"Failed to open step summary file, {summary_file_path_var} is not set.")
64+
return
65+
66+
try:
67+
self.file = open(summary_file_path, 'a')
68+
except Exception as ex:
69+
print_warning(f"Failed to open step summary file '{summary_file_path}': {ex}")
70+
71+
def __enter__(self):
72+
return self
73+
74+
def write_line(self, line: str = '') -> None:
75+
if self.file is None:
76+
return
77+
78+
self.file.write(line)
79+
self.file.write('\n')
80+
81+
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
82+
if self.file is not None:
83+
self.file.__exit__(exc_type, exc_val, exc_tb)
84+
4885
if __name__ == "__main__":
4986
args = sys.argv
5087

@@ -56,12 +93,12 @@ def pop_arg():
5693
result = args[0]
5794
args = args[1:]
5895
return result
59-
96+
6097
def done_parsing():
6198
if len(args) > 0:
6299
print_error("Bad command line, too many arguments specified.")
63100
sys.exit(1)
64-
101+
65102
pop_arg() # Skip script name
66103
command = pop_arg()
67104
if command == "print_error":
@@ -72,6 +109,10 @@ def done_parsing():
72109
message = pop_arg()
73110
done_parsing()
74111
print_warning(message)
112+
elif command == "print_notice":
113+
message = pop_arg()
114+
done_parsing()
115+
print_notice(message)
75116
elif command == "set_output":
76117
name = pop_arg()
77118
value = pop_arg()
@@ -89,5 +130,5 @@ def done_parsing():
89130
else:
90131
print_error(f"Unknown command '{command}'")
91132
sys.exit(1)
92-
133+
93134
fail_if_errors()

0 commit comments

Comments
 (0)