Skip to content

Commit 7c412db

Browse files
authored
Add a workflow to bake blueprint properties of props (#6752)
1 parent 829bf79 commit 7c412db

File tree

8 files changed

+395
-12
lines changed

8 files changed

+395
-12
lines changed
+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Copyright (c) 2025 Willem 'Jip' Wijnia
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to deal
5+
# in the Software without restriction, including without limitation the rights
6+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
# copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in all
11+
# copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
# SOFTWARE.
20+
21+
name: Bake blueprints
22+
23+
on:
24+
workflow_dispatch:
25+
inputs:
26+
blueprints:
27+
required: true
28+
type: choice
29+
description: The type of blueprints to bake properties into
30+
options:
31+
- props
32+
- units
33+
- projectiles
34+
- emitters
35+
36+
reference:
37+
required: true
38+
type: choice
39+
description: The reference (branch or tag) to use as a basis for baking.
40+
options:
41+
- develop
42+
- staging/faf
43+
- staging/fafbeta
44+
- staging/fafdevelop
45+
46+
env:
47+
COMMIT_MESSAGE: "Bake properties of ${{ inputs.blueprints }}\r\n\r\nThis commit originates from automation through GitHub Actions. The run was initiated by ${{ github.actor }}.\r\n\r\nThe run can be found at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}."
48+
PULL_REQUEST_BODY: "This pull request originates from automation through GitHub Actions. The run was initiated by ${{ github.actor }}.\r\n\r\nThe run can be found at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}. It involves the baking of properties into blueprints of ${{ inputs.blueprints }}. By baking in the properties we make it easier to understand the behavior of the blueprints."
49+
50+
jobs:
51+
bake-blueprints:
52+
runs-on: ubuntu-latest
53+
defaults:
54+
run:
55+
shell: bash
56+
57+
steps:
58+
# Checkout the wiki generator that we use to bake blueprints
59+
- name: Checkout Brewlan Wikigen Repository
60+
uses: actions/checkout@v4
61+
with:
62+
repository: The-Balthazar/BrewWikiGen
63+
path: ./brew-wiki-gen
64+
65+
# Checkout the FA repository
66+
- name: Checkout FAF Repository
67+
uses: actions/checkout@v4
68+
with:
69+
ref: ${{ inputs.reference }}
70+
ssh-key: ${{ secrets.SSH_FAFOREVER_MACHINE_USER }}
71+
path: ./fa
72+
sparse-checkout-cone-mode: false
73+
sparse-checkout: |
74+
*.lua
75+
*.bp
76+
77+
# Install the correct version of Lua for the wiki generator
78+
- name: Install Lua 5.4
79+
uses: leafo/gh-actions-lua@v10
80+
with:
81+
luaVersion: "5.4"
82+
83+
# Prepare the run file
84+
- name: Replace run.lua
85+
run: |
86+
FILE="fa/.github/workflows/scripts/baking/bake-${{ inputs.blueprints }}.lua"
87+
if [ ! -f "$FILE" ]; then
88+
echo "Error: File $FILE does not exist."
89+
exit 1
90+
fi
91+
92+
sudo cp "$FILE" brew-wiki-gen/Run.lua
93+
94+
# Use the wiki generator to bake the properties
95+
- name: Execute lua run
96+
run: |
97+
lua brew-wiki-gen/Run.lua --OutputDirectory="fa.wiki/" --WikiGeneratorDirectory="brew-wiki-gen/" --FADirectory="fa/"
98+
99+
# Create a branch, commit and pull request
100+
- name: Create a pull request
101+
if: github.event_name == 'workflow_dispatch'
102+
working-directory: fa
103+
run: |
104+
git config user.email "[email protected]"
105+
git config user.name "FAForever Machine User"
106+
107+
git checkout -b bake/${{ inputs.blueprints }}-${{ github.run_id }}
108+
109+
git stage .
110+
git commit -m "${{ env.COMMIT_MESSAGE }}"
111+
git push origin bake/${{ inputs.blueprints }}-${{ github.run_id }}
112+
113+
# Install GitHub CLI (gh)
114+
sudo apt update
115+
sudo apt install gh -y
116+
117+
# Authenticate gh (use GITHUB_TOKEN)
118+
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
119+
120+
# Create a pull request
121+
gh pr create \
122+
--title "Bake properties of ${{ inputs.blueprints }}" \
123+
--body "${{ env.PULL_REQUEST_BODY }}" \
124+
--base "${{ github.ref_name }}" \
125+
--head "bake/${{ inputs.blueprints }}-${{ github.run_id }}"
126+
127+
# Create a commit and push it
128+
- name: Create a commit
129+
if: github.event_name != 'workflow_dispatch'
130+
working-directory: fa
131+
run: |
132+
git config user.email "[email protected]"
133+
git config user.name "FAForever Machine User"
134+
135+
git add .
136+
git commit -m "${{ env.COMMIT_MESSAGE }}"
137+
git push
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
--------------------------------------------------------------------------------
2+
-- Supreme Commander mod automatic unit wiki generation script for Github wikis
3+
-- Copyright 2021-2022 Sean 'Balthazar' Wheeldon Lua 5.4.2
4+
--------------------------------------------------------------------------------
5+
6+
--[{ ---------------------------------------------------------------------- ]]--
7+
--[[ Inputs -- NOTE: Mod input files must be valid lua ]]--
8+
--[[ ---------------------------------------------------------------------- ]]--
9+
local OutputDirectory = "D:/faf-development/fa.wiki/"
10+
local WikiGeneratorDirectory = "D:/faf-development/BrewWikiGen/"
11+
local FADirectory = "D:/faf-development/fa/"
12+
13+
--#region This section deals with overriding the OutputDirectory and WikiGeneratorDirectory if required by command-line arguments
14+
15+
local function parse_args(arg)
16+
local args = {}
17+
for i = 1, #arg do
18+
local key, value = arg[i]:match("--([^=]+)=(.*)")
19+
if key and value then
20+
key = key:gsub("^%-+", "") -- Remove leading '-' characters
21+
args[key] = value
22+
end
23+
end
24+
return args
25+
end
26+
27+
local args = parse_args(arg)
28+
29+
-- Overwrite default values if provided as command-line arguments
30+
if args["OutputDirectory"] then
31+
OutputDirectory = args["OutputDirectory"]
32+
end
33+
if args["WikiGeneratorDirectory"] then
34+
WikiGeneratorDirectory = args["WikiGeneratorDirectory"]
35+
end
36+
if args["FADirectory"] then
37+
FADirectory = args["FADirectory"]
38+
end
39+
40+
print("Directories set")
41+
print("Output Directory: " ..OutputDirectory)
42+
print("Wiki Generator Directory: " ..WikiGeneratorDirectory)
43+
print("FA Directory: " ..FADirectory)
44+
--#endregion
45+
46+
EnvironmentData = {
47+
name = 'Forged Alliance',
48+
author = 'Gas Powered Games',
49+
version = '1.6.6',
50+
icon = false,
51+
location = FADirectory,
52+
53+
GenerateWikiPages = false,
54+
RebuildBlueprints = true,
55+
RunSanityChecks = false,
56+
57+
base64 = {
58+
UnitIcons = false,
59+
},
60+
61+
Lua = FADirectory,
62+
LOC = FADirectory,
63+
64+
PreModBlueprints = {},
65+
PostModBlueprints = {
66+
"BakePropBlueprints"
67+
},
68+
69+
LoadExtraBlueprints = {
70+
Beam = false,
71+
Mesh = false,
72+
Prop = true,
73+
Emitter = false,
74+
TrailEmitter = false,
75+
},
76+
}
77+
78+
WikiOptions = {
79+
Language = 'US', -- These are not ISO_639-1. As an Englishman I am offended.
80+
81+
GenerateHomePage = false,
82+
GenerateSidebar = false,
83+
GenerateModPages = false,
84+
GenerateUnitPages = false,
85+
GenerateProjectilesPage = false,
86+
GenerateCategoryPages = false,
87+
88+
-- Unit page options
89+
IncludeStrategicIcon = false,
90+
AbilityDescriptions = false,
91+
BalanceNote = '<LOC wiki_balance_stats_steam>Displayed stats are from when launched on the steam/retail version of the game.',
92+
ConstructionNote = '<LOC wiki_builders_note_steam>Build times from the Steam/retail version of the game:',
93+
BuildListSaysModUnits = false,
94+
95+
OnlineRepoUnitPageBlueprintLink = 'https://github.com/The-Balthazar/BrewLAN/tree/master/',
96+
LocalRepuUnitPageBlueprintLink = FADirectory,
97+
}
98+
99+
RebuildBlueprintOptions = {
100+
RebuildBpFiles = {
101+
Unit = false,
102+
Beam = false,
103+
Mesh = false,
104+
Prop = true,
105+
Emitter = false,
106+
Projectile = false,
107+
TrailEmitter = false,
108+
},
109+
RemoveUnusedValues = false,
110+
CleanupBuildOnLayerCaps = false,
111+
CleanupGeneralBackgroundIcon = false,
112+
CleanupWreckageLayers = false,
113+
CleanupCommandCaps = false,
114+
CleanupIntelOverlayCategories = false,
115+
RemoveMilitaryOverlayCategories = false,
116+
RemoveProductCategories = false,
117+
RecalculateThreat = false,
118+
}
119+
120+
CleanupOptions = {
121+
CleanUnitBpFiles = false,
122+
CleanUnitBpGeneral = false,
123+
CleanUnitBpDisplay = false,
124+
CleanUnitBpInterface = false,
125+
CleanUnitBpUseOOBTestZoom = false,
126+
CleanUnitBpThreat = false,
127+
}
128+
129+
ModDirectories = { -- In order
130+
-- 'C:/BrewLAN/mods/BrewLAN/',
131+
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewAir/',
132+
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewIntel/',
133+
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewMonsters/',
134+
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewResearch/',
135+
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewShields/',
136+
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewTeaParty/',
137+
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewTurrets/',
138+
}
139+
140+
BlueprintExclusions = {
141+
'/op[ec][^/]*_unit%.bp', --bp files like OPE2001
142+
'/[ux][arse]c[^/]*_unit%.bp', --Exclude civilian units.
143+
}
144+
145+
BlueprintIdExclusions = { -- Excludes blueprints with any of these IDs (case insensitive)
146+
"zxa0001", -- Dummy unit
147+
"zxa0002", -- Dummy unit for external/mobile factory units
148+
"zxa0003", -- Dummy unit
149+
"ura0001O", -- Cybran build drone
150+
"ura0002O", -- Cybran build drone
151+
"ura0003O", -- Cybran build drone
152+
"XRO4001", -- Remains of Dostya
153+
}
154+
155+
FooterCategories = { -- In order
156+
'UEF', 'AEON', 'CYBRAN', 'SERAPHIM',
157+
'TECH1', 'TECH2', 'TECH3', 'EXPERIMENTAL',
158+
'MOBILE',
159+
'ANTIAIR', 'ANTINAVY', 'DIRECTFIRE',
160+
'AIR', 'LAND', 'NAVAL',
161+
'HOVER',
162+
'ECONOMIC',
163+
'SHIELD', 'PERSONALSHIELD',
164+
'BOMBER', 'TORPEDOBOMBER',
165+
'MINE',
166+
'COMMAND', 'SUBCOMMANDER', 'ENGINEER', 'FIELDENGINEER',
167+
'TRANSPORTATION', 'AIRSTAGINGPLATFORM',
168+
'SILO',
169+
'FACTORY',
170+
'ARTILLERY',
171+
'STRUCTURE',
172+
}
173+
174+
Logging = { -- Functional logs
175+
LogEmojiSupported = false,
176+
177+
LocalisationLoaded = false,
178+
HelpStringsLoaded = false,
179+
BuffsLoaded = false,
180+
SCMLoadIssues = false,
181+
SandboxedFileLogs = {
182+
Debug = false, -- SPEW
183+
Log = true, -- LOG, _ALERT, print
184+
Warn = true, -- WARN
185+
},
186+
187+
ExcludedBlueprints = false,
188+
BlueprintTotals = true,
189+
MissingUnitImage = true,
190+
191+
ChangeDiscarded = true,
192+
NewFileWrites = true,
193+
FileAppendWrites = true,
194+
FileUpdateWrites = false,
195+
FileAssetCopies = true,
196+
197+
ThreatCalculationWarnings = false,
198+
}
199+
Sanity = { -- Advice logs
200+
BlueprintChecks = false,
201+
BlueprintPedanticChecks = false,
202+
BlueprintStrategicIconChecks = false,
203+
}
204+
Info = { -- Misc data logs
205+
UnitLODCounts = false,
206+
ProjectileBlueprintCounts = false,
207+
}
208+
209+
dofile(WikiGeneratorDirectory.."Main.lua")
210+
GeneratorMain(OutputDirectory)
211+

.github/workflows/test.yaml

+35-3
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,44 @@ jobs:
2323
- name: Checkout code
2424
uses: actions/checkout@v4
2525
with:
26+
sparse-checkout-cone-mode: false
2627
sparse-checkout: |
28+
# include all shell scripts used for testing
2729
*.sh
28-
*.lua
29-
*.bp
30+
31+
# include all Lua files that we ship
32+
env/**/*.lua
33+
meshes/**/*.lua
34+
projectiles/**/*.lua
35+
schook/**/*.lua
36+
effects/**/*.lua
37+
units/**/*.lua
38+
loc/**/*.lua
39+
etc/**/*.lua
40+
lua/**/*.lua
41+
textures/**/*.lua
42+
43+
# include all init files
44+
init_faf.lua
45+
init_fafdevelop.lua
46+
init_fafbeta.lua
47+
init_shared.lua
48+
init.lua
49+
init_local_development.lua
50+
mod_info.lua
51+
SupComDataPath.lua
52+
53+
# Include all blueprint files that we ship
54+
env/**/*.bp
55+
meshes/**/*.bp
56+
projectiles/**/*.bp
57+
schook/**/*.bp
58+
units/**/*.bp
59+
effects/**/*.bp
3060
- name: Check Lua syntax
31-
run: "bash ./tests/run-syntax-test.sh"
61+
run: |
62+
bash ./tests/run-syntax-test.sh
63+
3264
testUtils:
3365
name: Utility tests
3466
needs: [syntax]

changelog/snippets/fix.6752.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- (#6752) Fix (proper) use of sparse checkout cone mode to speed up CI/CD

0 commit comments

Comments
 (0)