Skip to content
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

Refactor of ModelPaths update script #4990

Merged
merged 3 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.csv
.wowtools.json
.wago_tools.json
atlas.lua
1 change: 1 addition & 0 deletions .github/scripts/.last_wow_build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
acb4ae782e4c990ef764592e78bc9e85
1 change: 1 addition & 0 deletions .github/scripts/.last_wow_classic_beta_build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
80b9d29886861d6f0225de09ca1d0476
1 change: 1 addition & 0 deletions .github/scripts/.last_wow_classic_build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ac0b091d8852985a2ce03e416fbf1cf1
1 change: 1 addition & 0 deletions .github/scripts/.last_wow_classic_era_build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5a468991f9812a6d3b2e08575c1211c2
1 change: 0 additions & 1 deletion .github/scripts/.lastclassicwowbuild

This file was deleted.

1 change: 0 additions & 1 deletion .github/scripts/.lastwow_classic_erabuild

This file was deleted.

1 change: 0 additions & 1 deletion .github/scripts/.lastwow_classicbuild

This file was deleted.

1 change: 0 additions & 1 deletion .github/scripts/.lastwowbuild

This file was deleted.

107 changes: 61 additions & 46 deletions .github/scripts/csv_to_lua.lua
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@

-- usage:
-- # lua.exe ./list_to_table.lua <release>

local releases = {
wow_classic_era = {
input = "wow_classic_era_list.csv", -- get it from https://wow.tools/casc/listfile/download/csv/build?buildConfig=9ad6ad5306deb8eed364b64cc628ac98
input = "wow_classic_era.csv",
output = "ModelPathsClassic.lua",
generate = true
generate = true,
},
wow_classic = {
input = "wow_classic_list.csv", -- get it from https://wow.tools/casc/listfile/download/csv/build?buildConfig=9ad6ad5306deb8eed364b64cc628ac98
output = "ModelPathsBCC.lua",
generate = true
input = "wow_classic.csv",
output = "ModelPathsWrath.lua",
generate = true,
},
wow_classic_beta = {
input = "wow_classic_beta.csv",
output = "ModelPathsCata.lua",
generate = true,
},
wow = {
input = "wow_list.csv", -- get it from https://wow.tools/casc/listfile/download/csv/build?buildConfig=26291f284f42494375d511d1fc120216 (last retail build when i write that)
input = "wow.csv",
output = "ModelPaths.lua",
generate = true
}
generate = true,
},
}

require "table"
require("table")

if not arg[1] or not releases[arg[1]] then
print(arg[0], "<wow|wow_classic|wow_classic_era>")
print(arg[0], "<wow|wow_classic|wow_classic_beta|wow_classic_era>")
return
end

Expand All @@ -40,9 +44,9 @@ local function recurseSet(var, key, value)
end
end
table.insert(var, idx, {
value = key,
text = key,
fileId = tostring(value),
value = key,
text = key,
fileId = tostring(value),
})
elseif todo == nil then
local idx = 1
Expand All @@ -54,19 +58,19 @@ local function recurseSet(var, key, value)
end
end
table.insert(var, idx, {
value = subkey,
text = subkey,
fileId = tostring(value),
})
value = subkey,
text = subkey,
fileId = tostring(value),
})
else
local tab
for k, v in pairs(var) do
if v.value == subkey then
tab = var[k].children
break
end
end
if tab == nil then
local tab
for k, v in pairs(var) do
if v.value == subkey then
tab = var[k].children
break
end
end
if tab == nil then
local idx = 1
for k, v in pairs(var) do
if subkey > v.value then
Expand All @@ -75,15 +79,15 @@ local function recurseSet(var, key, value)
break
end
end
tab = {
value = subkey,
text = subkey,
children = {},
}
table.insert(var, idx, tab)
tab = tab.children
end
recurseSet(tab, todo, value)
tab = {
value = subkey,
text = subkey,
children = {},
}
table.insert(var, idx, tab)
tab = tab.children
end
recurseSet(tab, todo, value)
end
end

Expand All @@ -98,21 +102,32 @@ local function serializeTable(val, name, skipnewlines, depth)
end

if type(val) == "table" then
tmp = tmp .. "{" .. (not skipnewlines and "\n" or "")
tmp = tmp .. "{" .. (not skipnewlines and "\n" or "")

for k, v in pairs(val) do
tmp = tmp .. serializeTable(v, k, skipnewlines, depth + 1) .. "," .. (not skipnewlines and "\n" or "")
end
-- Get the keys
local keys = {}
for k in pairs(val) do
table.insert(keys, k)
end

-- Sort the keys
table.sort(keys)

-- Iterate over the sorted keys
for _, k in ipairs(keys) do
local v = val[k]
tmp = tmp .. serializeTable(v, k, skipnewlines, depth + 1) .. "," .. (not skipnewlines and "\n" or "")
end

tmp = tmp .. string.rep(" ", depth) .. "}"
tmp = tmp .. string.rep(" ", depth) .. "}"
elseif type(val) == "number" then
tmp = tmp .. tostring(val)
tmp = tmp .. tostring(val)
elseif type(val) == "string" then
tmp = tmp .. string.format("%q", val)
tmp = tmp .. string.format("%q", val)
elseif type(val) == "boolean" then
tmp = tmp .. (val and "true" or "false")
tmp = tmp .. (val and "true" or "false")
else
tmp = tmp .. "\"[unserializable datatype:" .. type(val) .. "]\""
tmp = tmp .. '"[unserializable datatype:' .. type(val) .. ']"'
end

return tmp
Expand All @@ -122,9 +137,9 @@ local info = releases[arg[1]]
if info and info.generate then
local models = {}
for line in io.lines(info.input) do
local fileid, file = line:match("(%d*);(.*)")
local fileId, file = line:match("(%d*);(.*)")
if file and file:match("%.m2$") then
recurseSet(models, file, fileid)
recurseSet(models, file, fileId)
end
end

Expand Down
File renamed without changes.
42 changes: 42 additions & 0 deletions .github/scripts/update-model-paths.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

download_file() {
local url=$1
local output_file=$2

wget -O "${output_file}" "${url}" || { echo "Error while downloading ${output_file}"; exit 1; }
}

update_model_paths() {
local branch=$1
local build_config

build_config=$(jq -r ".${branch}.build_config" < .wago_tools.json)
if [ -z "${build_config}" ] || [ "${build_config}" == "null" ]; then
echo "${branch} build_config not found in .wago_tools.json"
return
fi

local last_build_file=".last_${branch}_build"
if [ -f "${last_build_file}" ] && [[ ${build_config} == $(cat "${last_build_file}") ]]; then
echo "${branch} build_config has not changed"
return
fi

echo "New ${branch} build detected"
local csv_file="${branch}.csv"
download_file "https://wago.tools/api/files?branch=${branch}&search=.m2&format=csv" "${csv_file}"
echo "${build_config}" > "${last_build_file}"
lua csv_to_lua.lua "${branch}" || { echo "Error while creating ${branch}.lua"; exit 1; }
}

download_file "https://wago.tools/api/builds/latest" ".wago_tools.json"

branches=("wow" "wow_classic" "wow_classic_beta" "wow_classic_era")

for branch in "${branches[@]}"
do
update_model_paths "$branch"
done

mv ModelPaths*.lua ../../WeakAurasModelPaths/
35 changes: 0 additions & 35 deletions .github/scripts/wowtools.sh

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/atlas-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Create Atlas File List Update Pull Request
on:
schedule:
- cron: "0 10 * * 1"

workflow_dispatch:

jobs:
Expand All @@ -22,7 +21,7 @@ jobs:
- name: Update Atlas Files from wago.tools
run: |
cd .github/scripts/
./wagotools-atlas.sh
./update-atlas-files.sh
shell: bash

- name: Cleanup Luarocks
Expand All @@ -35,4 +34,5 @@ jobs:
branch: update-atlasfiles
commit-message: Update Atlas File List from wago.tools
title: Update Atlas File List from wago.tools
body: Update Atlas File List from wago.tools
delete-branch: true
28 changes: 28 additions & 0 deletions .github/workflows/modelpaths-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Create WeakAurasModelPaths Update Pull Request

on:
schedule:
- cron: "0 10 * * 1"
workflow_dispatch:

jobs:
modelPathsUpdate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: leafo/gh-actions-lua@v10

- name: Update WeakAurasModelPaths from wago.tools
run: |
cd .github/scripts/
./update-model-paths.sh
shell: bash

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
branch: update-modelpaths
commit-message: Update WeakAurasModelPaths from wago.tools
title: Update WeakAurasModelPaths from wago.tools
body: Update WeakAurasModelPaths from wago.tools
delete-branch: true
28 changes: 0 additions & 28 deletions .github/workflows/modelpaths-update.yml.disabled

This file was deleted.

1 change: 1 addition & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
],
"runtime.version": "Lua 5.1",
"workspace.ignoreDir": [
".github",
".vscode",
"WeakAurasModelPaths",
"WeakAuras/Libs"
Expand Down
Loading