Repository navigation
131 lines (116 loc) · 5.43 KB
/
Copy pathProtoRefresh.yml
File metadata and controls
131 lines (116 loc) · 5.43 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
name: Proto Refresh Check
# Authoritatively checks whether the Rust dedicated server's Companion contracts have drifted
# from the committed RustPlusContracts.proto (Method A — see tools/update-proto/README.md).
# On drift it opens (or comments on) a tracking issue with the diff; the regenerated proto is
# NOT auto-applied because new fields usually need matching model/mapper changes by hand.
on:
schedule:
# Rust force-updates on the first Thursday of each month (~18:00–20:00 UTC). cron can't
# express "first Thursday", so run every Thursday at 21:00 UTC and gate on the day-of-month.
- cron: "0 21 * * 4"
workflow_dispatch: {}
permissions:
contents: read
issues: write
jobs:
proto-refresh:
runs-on: ubuntu-latest
steps:
- name: First-Thursday gate
id: gate
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "run=true" >> "$GITHUB_OUTPUT"
elif [ "$(date -u +%-d)" -le 7 ]; then
echo "run=true" >> "$GITHUB_OUTPUT"
else
echo "run=false" >> "$GITHUB_OUTPUT"
echo "::notice::Not the first Thursday of the month — skipping."
fi
- name: Checkout
if: steps.gate.outputs.run == 'true'
uses: actions/checkout@v7
- name: Setup .NET
if: steps.gate.outputs.run == 'true'
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
- name: Install SteamCMD runtime deps (32-bit)
if: steps.gate.outputs.run == 'true'
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y --no-install-recommends lib32gcc-s1
- name: Run proto refresh
if: steps.gate.outputs.run == 'true'
id: refresh
run: |
set +e
./tools/update-proto/update-proto.sh
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
exit 0
# The decompiled contracts are the input ProtoGen parses. Keeping them lets a
# surprising diff be traced back to the exact decompiled shape without re-running the
# multi-GB fetch — the drift issue alone is not enough to debug a parser regression.
- name: Upload decompiled contracts artifact
if: always() && steps.gate.outputs.run == 'true'
uses: actions/upload-artifact@v7
with:
name: decompiled-contracts
path: tools/update-proto/decompiled/
if-no-files-found: warn
- name: Upload diff artifact
if: steps.gate.outputs.run == 'true' && steps.refresh.outputs.exit_code == '1'
uses: actions/upload-artifact@v7
with:
name: proto-diff
path: tools/update-proto/out/proto.diff
# 0 = clean, 1 = drift (handled below). Anything else is a pipeline/tool failure —
# notably ProtoGen's field-loss guard (exit 3) — and must go red rather than quietly
# producing no issue.
- name: Fail on pipeline error
if: steps.gate.outputs.run == 'true' && steps.refresh.outputs.exit_code != '0' && steps.refresh.outputs.exit_code != '1'
run: |
echo "::error::proto refresh failed with exit code ${{ steps.refresh.outputs.exit_code }} — see the 'Run proto refresh' step."
exit 1
- name: Open or update drift issue
if: steps.gate.outputs.run == 'true' && steps.refresh.outputs.exit_code == '1'
env:
GH_TOKEN: ${{ github.token }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -euo pipefail
manifest="tools/update-proto/rds/steamapps/appmanifest_258550.acf"
build_id="$(grep -o '"buildid"[^0-9]*[0-9]*' "$manifest" 2>/dev/null | grep -o '[0-9]*' || echo unknown)"
ilspy_version="$(cat tools/update-proto/decompiled/.ilspy-version 2>/dev/null || echo unknown)"
{
echo "The Rust dedicated server's Companion contracts have drifted from the committed"
echo "\`src/RustPlusApi/Protobuf/RustPlusContracts.proto\`."
echo
echo "- **Server build id:** \`${build_id}\`"
echo "- **Workflow run:** ${RUN_URL}"
echo "- **Decompiler:** \`ilspycmd ${ilspy_version}\`"
echo
echo "Review the diff and apply the genuine wire changes (plus any matching \`Data/*\` model"
echo "and \`Extensions/*\` mapper updates), then open a PR. See \`tools/update-proto/README.md\`."
echo
echo "<details><summary>Diff (committed → server)</summary>"
echo
echo '```diff'
cat tools/update-proto/out/proto.diff
echo '```'
echo
echo "</details>"
} > /tmp/drift-body.md
# Ensure the label exists (no-op if it already does).
gh label create proto-drift --color FBCA04 \
--description "Committed proto drifted from the Rust dedicated server" 2>/dev/null || true
existing="$(gh issue list --label proto-drift --state open --json number --jq '.[0].number // empty')"
if [ -n "$existing" ]; then
gh issue comment "$existing" --body-file /tmp/drift-body.md
echo "::notice::Updated existing drift issue #${existing}."
else
gh issue create --label proto-drift \
--title "Proto drift detected (server build ${build_id})" \
--body-file /tmp/drift-body.md
fi