Skip to content

Add a workflow to bake blueprint properties of props #6752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 50 commits into from
May 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
cd759c2
Add a workflow file to bake blueprint properties
Garanas Apr 27, 2025
d25ae78
Copy from the `fa` folder
Garanas Apr 27, 2025
c23a0dd
Listen to program arguments
Garanas Apr 27, 2025
2fb8ac5
Copy instead of moving the run file
Garanas Apr 27, 2025
4279c8b
Add some dummy changes for testing purposes
Garanas Apr 27, 2025
28541b7
Replace all the references
Garanas Apr 27, 2025
65fd322
Rebuild prop blueprints
Garanas Apr 27, 2025
d2f086c
Fix a Lua syntax error
Garanas Apr 29, 2025
e569dc4
Add a snippet
Garanas Apr 29, 2025
7d29420
Use the SSH key of the machine user of FAForever
Garanas Apr 29, 2025
276fad3
Update changelog/snippets/other.6752.md
Garanas Apr 29, 2025
6c3a914
Update .github/workflows/scripts/baking/bake-props.lua
Garanas Apr 29, 2025
3ecae80
Use cone mode properly
Garanas Apr 29, 2025
2c65bef
Try and fix sparse checkout
Garanas Apr 29, 2025
abca223
Try and fix sparse checkout
Garanas Apr 29, 2025
20e4eeb
Ignore all Lua files inside the .github folder
Garanas Apr 29, 2025
a480f06
Create a commit or pull request depending on the workflow event
Garanas Apr 29, 2025
eedf195
Add some change to commit
Garanas Apr 29, 2025
d8cf191
Stage files instead of add
Garanas Apr 29, 2025
8501dd8
Make changes that should be detected when rebuilding
Garanas Apr 29, 2025
642488c
Derp, include the blueprint post processing lua files
Garanas Apr 29, 2025
5182a4c
Include all source files
Garanas Apr 29, 2025
b7c08af
Allow the commit to fail
Garanas Apr 29, 2025
5a0cdaf
Use the reference input
Garanas Apr 29, 2025
bb95980
Update .github/workflows/scripts/baking/bake-props.lua
Garanas Apr 29, 2025
18e8b4e
Use the reference variable - not the string value
Garanas Apr 29, 2025
de9b184
Adjust the naming convention for baking properties
Garanas Apr 29, 2025
3eb6565
Fix the description of the reference input
Garanas May 1, 2025
a115269
Tweak descriptions and properties of the baking workflow
Garanas May 1, 2025
e3e5be3
Ignore Lua in the .Github folder when checking syntax
Garanas May 1, 2025
2c0450a
Do not use cone mode when checking out for the test
Garanas May 1, 2025
c35f2d5
Specify only files that we ship for syntax test
Garanas May 1, 2025
5c38624
Add all files inside folders
Garanas May 1, 2025
67dc0e9
Add missing Lua files
Garanas May 1, 2025
2aa8452
Use a double asterisk to catch remaining Lua files
Garanas May 1, 2025
05cf922
Try and catch all Lua files
Garanas May 1, 2025
80dd64c
Decipher what 100 files we're missing
Garanas May 1, 2025
2d70411
Add missing asterisk
Garanas May 1, 2025
1b2804b
Add Lua files inside the textures folder
Garanas May 1, 2025
d6ff0cb
Include the textures folder
Garanas May 1, 2025
63d014a
Remove debug statement
Garanas May 1, 2025
ec0e668
Add details to the commit message
Garanas May 2, 2025
8382e03
Add more details to the pull request body
Garanas May 2, 2025
774f626
Match the name of the job with its purpose
Garanas May 2, 2025
7b449c3
Remove spaces to indicate the creation of a variable
Garanas May 2, 2025
97f13c0
Do not add more details to the pull request body
Garanas May 2, 2025
2a62523
Remove space after the use of `\`
Garanas May 2, 2025
9b970bb
Add a more descriptive pull request
Garanas May 2, 2025
b453a69
Remove dummy changes to test
Garanas May 2, 2025
90f3664
Add a snippet about changes to the test workflow
Garanas May 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions .github/workflows/bake-blueprints.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Copyright (c) 2025 Willem 'Jip' Wijnia
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

name: Bake blueprints

on:
workflow_dispatch:
inputs:
blueprints:
required: true
type: choice
description: The type of blueprints to bake properties into
options:
- props
- units
- projectiles
- emitters

reference:
required: true
type: choice
description: The reference (branch or tag) to use as a basis for baking.
options:
- develop
- staging/faf
- staging/fafbeta
- staging/fafdevelop

env:
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 }}."
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."

jobs:
bake-blueprints:
runs-on: ubuntu-latest
defaults:
run:
shell: bash

steps:
# Checkout the wiki generator that we use to bake blueprints
- name: Checkout Brewlan Wikigen Repository
uses: actions/checkout@v4
with:
repository: The-Balthazar/BrewWikiGen
path: ./brew-wiki-gen

# Checkout the FA repository
- name: Checkout FAF Repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.reference }}
ssh-key: ${{ secrets.SSH_FAFOREVER_MACHINE_USER }}
path: ./fa
sparse-checkout-cone-mode: false
sparse-checkout: |
*.lua
*.bp

# Install the correct version of Lua for the wiki generator
- name: Install Lua 5.4
uses: leafo/gh-actions-lua@v10
with:
luaVersion: "5.4"

# Prepare the run file
- name: Replace run.lua
run: |
FILE="fa/.github/workflows/scripts/baking/bake-${{ inputs.blueprints }}.lua"
if [ ! -f "$FILE" ]; then
echo "Error: File $FILE does not exist."
exit 1
fi

sudo cp "$FILE" brew-wiki-gen/Run.lua

# Use the wiki generator to bake the properties
- name: Execute lua run
run: |
lua brew-wiki-gen/Run.lua --OutputDirectory="fa.wiki/" --WikiGeneratorDirectory="brew-wiki-gen/" --FADirectory="fa/"

# Create a branch, commit and pull request
- name: Create a pull request
if: github.event_name == 'workflow_dispatch'
working-directory: fa
run: |
git config user.email "[email protected]"
git config user.name "FAForever Machine User"

git checkout -b bake/${{ inputs.blueprints }}-${{ github.run_id }}

git stage .
git commit -m "${{ env.COMMIT_MESSAGE }}"
git push origin bake/${{ inputs.blueprints }}-${{ github.run_id }}

# Install GitHub CLI (gh)
sudo apt update
sudo apt install gh -y

# Authenticate gh (use GITHUB_TOKEN)
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token

# Create a pull request
gh pr create \
--title "Bake properties of ${{ inputs.blueprints }}" \
--body "${{ env.PULL_REQUEST_BODY }}" \
--base "${{ github.ref_name }}" \
--head "bake/${{ inputs.blueprints }}-${{ github.run_id }}"

# Create a commit and push it
- name: Create a commit
if: github.event_name != 'workflow_dispatch'
working-directory: fa
run: |
git config user.email "[email protected]"
git config user.name "FAForever Machine User"

git add .
git commit -m "${{ env.COMMIT_MESSAGE }}"
git push
211 changes: 211 additions & 0 deletions .github/workflows/scripts/baking/bake-props.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
--------------------------------------------------------------------------------
-- Supreme Commander mod automatic unit wiki generation script for Github wikis
-- Copyright 2021-2022 Sean 'Balthazar' Wheeldon Lua 5.4.2
--------------------------------------------------------------------------------

--[{ ---------------------------------------------------------------------- ]]--
--[[ Inputs -- NOTE: Mod input files must be valid lua ]]--
--[[ ---------------------------------------------------------------------- ]]--
local OutputDirectory = "D:/faf-development/fa.wiki/"
local WikiGeneratorDirectory = "D:/faf-development/BrewWikiGen/"
local FADirectory = "D:/faf-development/fa/"

--#region This section deals with overriding the OutputDirectory and WikiGeneratorDirectory if required by command-line arguments

local function parse_args(arg)
local args = {}
for i = 1, #arg do
local key, value = arg[i]:match("--([^=]+)=(.*)")
if key and value then
key = key:gsub("^%-+", "") -- Remove leading '-' characters
args[key] = value
end
end
return args
end

local args = parse_args(arg)

-- Overwrite default values if provided as command-line arguments
if args["OutputDirectory"] then
OutputDirectory = args["OutputDirectory"]
end
if args["WikiGeneratorDirectory"] then
WikiGeneratorDirectory = args["WikiGeneratorDirectory"]
end
if args["FADirectory"] then
FADirectory = args["FADirectory"]
end

print("Directories set")
print("Output Directory: " ..OutputDirectory)
print("Wiki Generator Directory: " ..WikiGeneratorDirectory)
print("FA Directory: " ..FADirectory)
--#endregion

EnvironmentData = {
name = 'Forged Alliance',
author = 'Gas Powered Games',
version = '1.6.6',
icon = false,
location = FADirectory,

GenerateWikiPages = false,
RebuildBlueprints = true,
RunSanityChecks = false,

base64 = {
UnitIcons = false,
},

Lua = FADirectory,
LOC = FADirectory,

PreModBlueprints = {},
PostModBlueprints = {
"BakePropBlueprints"
},

LoadExtraBlueprints = {
Beam = false,
Mesh = false,
Prop = true,
Emitter = false,
TrailEmitter = false,
},
}

WikiOptions = {
Language = 'US', -- These are not ISO_639-1. As an Englishman I am offended.

GenerateHomePage = false,
GenerateSidebar = false,
GenerateModPages = false,
GenerateUnitPages = false,
GenerateProjectilesPage = false,
GenerateCategoryPages = false,

-- Unit page options
IncludeStrategicIcon = false,
AbilityDescriptions = false,
BalanceNote = '<LOC wiki_balance_stats_steam>Displayed stats are from when launched on the steam/retail version of the game.',
ConstructionNote = '<LOC wiki_builders_note_steam>Build times from the Steam/retail version of the game:',
BuildListSaysModUnits = false,

OnlineRepoUnitPageBlueprintLink = 'https://github.com/The-Balthazar/BrewLAN/tree/master/',
LocalRepuUnitPageBlueprintLink = FADirectory,
}

RebuildBlueprintOptions = {
RebuildBpFiles = {
Unit = false,
Beam = false,
Mesh = false,
Prop = true,
Emitter = false,
Projectile = false,
TrailEmitter = false,
},
RemoveUnusedValues = false,
CleanupBuildOnLayerCaps = false,
CleanupGeneralBackgroundIcon = false,
CleanupWreckageLayers = false,
CleanupCommandCaps = false,
CleanupIntelOverlayCategories = false,
RemoveMilitaryOverlayCategories = false,
RemoveProductCategories = false,
RecalculateThreat = false,
}

CleanupOptions = {
CleanUnitBpFiles = false,
CleanUnitBpGeneral = false,
CleanUnitBpDisplay = false,
CleanUnitBpInterface = false,
CleanUnitBpUseOOBTestZoom = false,
CleanUnitBpThreat = false,
}

ModDirectories = { -- In order
-- 'C:/BrewLAN/mods/BrewLAN/',
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewAir/',
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewIntel/',
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewMonsters/',
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewResearch/',
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewShields/',
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewTeaParty/',
-- 'C:/BrewLAN/mods/BrewLAN_Units/BrewTurrets/',
}

BlueprintExclusions = {
'/op[ec][^/]*_unit%.bp', --bp files like OPE2001
'/[ux][arse]c[^/]*_unit%.bp', --Exclude civilian units.
}

BlueprintIdExclusions = { -- Excludes blueprints with any of these IDs (case insensitive)
"zxa0001", -- Dummy unit
"zxa0002", -- Dummy unit for external/mobile factory units
"zxa0003", -- Dummy unit
"ura0001O", -- Cybran build drone
"ura0002O", -- Cybran build drone
"ura0003O", -- Cybran build drone
"XRO4001", -- Remains of Dostya
}

FooterCategories = { -- In order
'UEF', 'AEON', 'CYBRAN', 'SERAPHIM',
'TECH1', 'TECH2', 'TECH3', 'EXPERIMENTAL',
'MOBILE',
'ANTIAIR', 'ANTINAVY', 'DIRECTFIRE',
'AIR', 'LAND', 'NAVAL',
'HOVER',
'ECONOMIC',
'SHIELD', 'PERSONALSHIELD',
'BOMBER', 'TORPEDOBOMBER',
'MINE',
'COMMAND', 'SUBCOMMANDER', 'ENGINEER', 'FIELDENGINEER',
'TRANSPORTATION', 'AIRSTAGINGPLATFORM',
'SILO',
'FACTORY',
'ARTILLERY',
'STRUCTURE',
}

Logging = { -- Functional logs
LogEmojiSupported = false,

LocalisationLoaded = false,
HelpStringsLoaded = false,
BuffsLoaded = false,
SCMLoadIssues = false,
SandboxedFileLogs = {
Debug = false, -- SPEW
Log = true, -- LOG, _ALERT, print
Warn = true, -- WARN
},

ExcludedBlueprints = false,
BlueprintTotals = true,
MissingUnitImage = true,

ChangeDiscarded = true,
NewFileWrites = true,
FileAppendWrites = true,
FileUpdateWrites = false,
FileAssetCopies = true,

ThreatCalculationWarnings = false,
}
Sanity = { -- Advice logs
BlueprintChecks = false,
BlueprintPedanticChecks = false,
BlueprintStrategicIconChecks = false,
}
Info = { -- Misc data logs
UnitLODCounts = false,
ProjectileBlueprintCounts = false,
}

dofile(WikiGeneratorDirectory.."Main.lua")
GeneratorMain(OutputDirectory)

38 changes: 35 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,44 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout-cone-mode: false
sparse-checkout: |
# include all shell scripts used for testing
*.sh
*.lua
*.bp

# include all Lua files that we ship
env/**/*.lua
meshes/**/*.lua
projectiles/**/*.lua
schook/**/*.lua
effects/**/*.lua
units/**/*.lua
loc/**/*.lua
etc/**/*.lua
lua/**/*.lua
textures/**/*.lua

# include all init files
init_faf.lua
init_fafdevelop.lua
init_fafbeta.lua
init_shared.lua
init.lua
init_local_development.lua
mod_info.lua
SupComDataPath.lua

# Include all blueprint files that we ship
env/**/*.bp
meshes/**/*.bp
projectiles/**/*.bp
schook/**/*.bp
units/**/*.bp
effects/**/*.bp
- name: Check Lua syntax
run: "bash ./tests/run-syntax-test.sh"
run: |
bash ./tests/run-syntax-test.sh

testUtils:
name: Utility tests
needs: [syntax]
Expand Down
1 change: 1 addition & 0 deletions changelog/snippets/fix.6752.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#6752) Fix (proper) use of sparse checkout cone mode to speed up CI/CD
Loading
Loading