From 3358a2b51609b6510b6e971e1e8ba844af978acb Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 4 Aug 2023 20:40:24 -0700 Subject: [PATCH 1/6] enable more tests --- ci/test.lua | 1 + plugins/lua/blueprint.lua | 2 +- test/library/gui/widgets.Label.lua | 2 +- test/library/helpdb.lua | 2 +- test/plugins/blueprint.lua | 26 ++++++++++++++------------ test/plugins/cxxrandom.lua | 2 ++ test/plugins/orders.lua | 1 + test/plugins/workflow.lua | 2 ++ test/quickfort/ecosystem.lua | 1 + test/structures/misc.lua | 2 +- 10 files changed, 25 insertions(+), 16 deletions(-) diff --git a/ci/test.lua b/ci/test.lua index bb12f6be1..01168800b 100644 --- a/ci/test.lua +++ b/ci/test.lua @@ -553,6 +553,7 @@ local function run_tests(tests, status, counts, config) goto skip end if not MODES[test.config.mode].detect() then + print(('Switching to %s mode for test: %s'):format(test.config.mode, test.name)) local ok, err = pcall(MODES[test.config.mode].navigate, config) if not ok then MODES[test.config.mode].failed = true diff --git a/plugins/lua/blueprint.lua b/plugins/lua/blueprint.lua index 57dee31fc..6aa154d2d 100644 --- a/plugins/lua/blueprint.lua +++ b/plugins/lua/blueprint.lua @@ -207,7 +207,7 @@ end -- returns the name of the output file for the given context function get_filename(opts, phase, ordinal) local fullname = 'dfhack-config/blueprints/' .. opts.name - local _,_,basename = fullname:find('/([^/]+)/?$') + local _,_,basename = opts.name:find('([^/]+)/*$') if not basename then -- should not happen since opts.name should already be validated error(('could not parse basename out of "%s"'):format(fullname)) diff --git a/test/library/gui/widgets.Label.lua b/test/library/gui/widgets.Label.lua index 75acba490..09ead7ad5 100644 --- a/test/library/gui/widgets.Label.lua +++ b/test/library/gui/widgets.Label.lua @@ -3,7 +3,7 @@ config.target = 'core' local gui = require('gui') local widgets = require('gui.widgets') -local fs = defclass(fs, gui.FramedScreen) +local fs = defclass(nil, gui.FramedScreen) fs.ATTRS = { frame_style = gui.GREY_LINE_FRAME, frame_title = 'TestFramedScreen', diff --git a/test/library/helpdb.lua b/test/library/helpdb.lua index bc482582c..7be2488df 100644 --- a/test/library/helpdb.lua +++ b/test/library/helpdb.lua @@ -1,4 +1,4 @@ -config.target = 'core' +--config.target = 'core' local h = require('helpdb') diff --git a/test/plugins/blueprint.lua b/test/plugins/blueprint.lua index 6146aea3f..35d32e1ff 100644 --- a/test/plugins/blueprint.lua +++ b/test/plugins/blueprint.lua @@ -1,3 +1,5 @@ +config.target = 'blueprint' + local b = require('plugins.blueprint') -- also covers code shared between parse_gui_commandline and parse_commandline @@ -117,9 +119,9 @@ function test.parse_gui_commandline() function() b.parse_gui_commandline({}, {''}) end) opts = {} - b.parse_gui_commandline(opts, {'imaname', 'dig', 'query'}) + b.parse_gui_commandline(opts, {'imaname', 'dig', 'place'}) expect.table_eq({auto_phase=false, format='minimal', split_strategy='none', - name='imaname', dig=true, query=true}, + name='imaname', dig=true, place=true}, opts) expect.error_match('unknown phase', @@ -203,9 +205,9 @@ function test.do_phase_positive_dims() function() local spos = {x=10, y=20, z=30} local epos = {x=11, y=21, z=31} - b.query(spos, epos, 'imaname') + b.place(spos, epos, 'imaname') expect.eq(1, mock_run.call_count) - expect.table_eq({'2', '2', '2', 'imaname', 'query', + expect.table_eq({'2', '2', '2', 'imaname', 'place', '--cursor=10,20,30'}, mock_run.call_args[1]) end) @@ -217,9 +219,9 @@ function test.do_phase_negative_dims() function() local spos = {x=11, y=21, z=31} local epos = {x=10, y=20, z=30} - b.query(spos, epos, 'imaname') + b.place(spos, epos, 'imaname') expect.eq(1, mock_run.call_count) - expect.table_eq({'2', '2', '-2', 'imaname', 'query', + expect.table_eq({'2', '2', '-2', 'imaname', 'place', '--cursor=10,20,31'}, mock_run.call_args[1]) end) @@ -231,9 +233,9 @@ function test.do_phase_ensure_cursor_is_at_upper_left() function() local spos = {x=11, y=20, z=30} local epos = {x=10, y=21, z=31} - b.query(spos, epos, 'imaname') + b.place(spos, epos, 'imaname') expect.eq(1, mock_run.call_count) - expect.table_eq({'2', '2', '2', 'imaname', 'query', + expect.table_eq({'2', '2', '2', 'imaname', 'place', '--cursor=10,20,30'}, mock_run.call_args[1]) end) @@ -241,16 +243,16 @@ end function test.get_filename() local opts = {name='a', split_strategy='none'} - expect.eq('blueprints/a.csv', b.get_filename(opts, 'dig', 1)) + expect.eq('dfhack-config/blueprints/a.csv', b.get_filename(opts, 'dig', 1)) opts = {name='a/', split_strategy='none'} - expect.eq('blueprints/a/a.csv', b.get_filename(opts, 'dig', 1)) + expect.eq('dfhack-config/blueprints/a/a.csv', b.get_filename(opts, 'dig', 1)) opts = {name='a', split_strategy='phase'} - expect.eq('blueprints/a-1-dig.csv', b.get_filename(opts, 'dig', 1)) + expect.eq('dfhack-config/blueprints/a-1-dig.csv', b.get_filename(opts, 'dig', 1)) opts = {name='a/', split_strategy='phase'} - expect.eq('blueprints/a/a-5-dig.csv', b.get_filename(opts, 'dig', 5)) + expect.eq('dfhack-config/blueprints/a/a-5-dig.csv', b.get_filename(opts, 'dig', 5)) expect.error_match('could not parse basename', function() b.get_filename({name='', split_strategy='none'}) diff --git a/test/plugins/cxxrandom.lua b/test/plugins/cxxrandom.lua index 6b11e1937..997cb2cb3 100644 --- a/test/plugins/cxxrandom.lua +++ b/test/plugins/cxxrandom.lua @@ -1,3 +1,5 @@ +config.target = 'cxxrandom' + local rng = require('plugins.cxxrandom') function test.cxxrandom_distributions() diff --git a/test/plugins/orders.lua b/test/plugins/orders.lua index a0959ae94..c5fae8eb2 100644 --- a/test/plugins/orders.lua +++ b/test/plugins/orders.lua @@ -1,4 +1,5 @@ config.mode = 'fortress' +--config.target = 'orders' local FILE_PATH_PATTERN = 'dfhack-config/orders/%s.json' diff --git a/test/plugins/workflow.lua b/test/plugins/workflow.lua index a03d1c2f6..8d0c69c68 100644 --- a/test/plugins/workflow.lua +++ b/test/plugins/workflow.lua @@ -1,3 +1,5 @@ +config.target = 'workflow' + local workflow = require('plugins.workflow') function test.job_outputs() diff --git a/test/quickfort/ecosystem.lua b/test/quickfort/ecosystem.lua index 3a4c014e4..bbe16319f 100644 --- a/test/quickfort/ecosystem.lua +++ b/test/quickfort/ecosystem.lua @@ -26,6 +26,7 @@ -- crashing the game. config.mode = 'fortress' +config.target = {'quickfort', 'blueprint', 'dig-now', 'tiletypes', 'gui/quantum'} local argparse = require('argparse') local gui = require('gui') diff --git a/test/structures/misc.lua b/test/structures/misc.lua index e93491d66..13febff56 100644 --- a/test/structures/misc.lua +++ b/test/structures/misc.lua @@ -28,7 +28,7 @@ function test.viewscreenDtors() for name, type in pairs(df) do if name:startswith('viewscreen') then print('testing', name) - v = type:new() + local v = type:new() expect.true_(v:delete(), "destructor returned false: " .. name) end end From c323576c1e364e995a5e072c7a6582e549e06dd3 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 4 Aug 2023 23:31:01 -0700 Subject: [PATCH 2/6] build docs for tests so the harness can identify unavailables --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61eb70aad..c74b559ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,7 @@ jobs: structures_ref: ${{ inputs.structures_ref }} artifact-name: test-msvc cache-id: test + docs: true tests: true build-linux: @@ -33,6 +34,7 @@ jobs: cache-id: test stonesense: ${{ matrix.plugins == 'all' }} extras: ${{ matrix.plugins == 'all' }} + docs: true tests: true gcc-ver: ${{ matrix.gcc }} secrets: inherit From 7981624792ff1510f29eedd57fcc61542fd4156e Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 4 Aug 2023 23:59:04 -0700 Subject: [PATCH 3/6] don't build html docs unless we have to --- .github/workflows/build-linux.yml | 4 ++++ .github/workflows/build-windows.yml | 5 ++++- .github/workflows/test.yml | 2 ++ CMakeLists.txt | 23 +++++++++++++++++------ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index a4609128b..f7088a234 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -29,6 +29,9 @@ on: docs: type: boolean default: false + html: + type: boolean + default: true stonesense: type: boolean default: false @@ -118,6 +121,7 @@ jobs: -DBUILD_SIZECHECK:BOOL=${{ inputs.extras }} \ -DBUILD_SKELETON:BOOL=${{ inputs.extras }} \ -DBUILD_DOCS:BOOL=${{ inputs.docs }} \ + -DBUILD_DOCS_NO_HTML:BOOL=${{ !inputs.html }} \ -DBUILD_TESTS:BOOL=${{ inputs.tests }} \ -DBUILD_XMLDUMP:BOOL=${{ inputs.xml-dump-type-sizes }} \ -DINSTALL_DATA_FILES:BOOL=${{ inputs.common-files }} \ diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 987dfc562..50d7f6936 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -29,6 +29,9 @@ on: docs: type: boolean default: false + html: + type: boolean + default: true stonesense: type: boolean default: false @@ -91,7 +94,7 @@ jobs: win-msvc - name: Cross-compile env: - CMAKE_EXTRA_ARGS: '-DBUILD_LIBRARY=${{ inputs.platform-files }} -DBUILD_STONESENSE:BOOL=${{ inputs.stonesense }} -DBUILD_DOCS:BOOL=${{ inputs.docs }} -DINSTALL_DATA_FILES:BOOL=${{ inputs.common-files }} -DINSTALL_SCRIPTS:BOOL=${{ inputs.common-files }} -DBUILD_DFLAUNCH:BOOL=${{ inputs.launchdf }} -DBUILD_TESTS:BOOL=${{ inputs.tests }} -DBUILD_XMLDUMP:BOOL=${{ inputs.xml-dump-type-sizes }}' + CMAKE_EXTRA_ARGS: '-DBUILD_LIBRARY=${{ inputs.platform-files }} -DBUILD_STONESENSE:BOOL=${{ inputs.stonesense }} -DBUILD_DOCS:BOOL=${{ inputs.docs }} -DBUILD_DOCS_NO_HTML:BOOL=${{ !inputs.html }} -DINSTALL_DATA_FILES:BOOL=${{ inputs.common-files }} -DINSTALL_SCRIPTS:BOOL=${{ inputs.common-files }} -DBUILD_DFLAUNCH:BOOL=${{ inputs.launchdf }} -DBUILD_TESTS:BOOL=${{ inputs.tests }} -DBUILD_XMLDUMP:BOOL=${{ inputs.xml-dump-type-sizes }}' run: | cd build bash -x build-win64-from-linux.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c74b559ea..0934d6d00 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,7 @@ jobs: artifact-name: test-msvc cache-id: test docs: true + html: false tests: true build-linux: @@ -35,6 +36,7 @@ jobs: stonesense: ${{ matrix.plugins == 'all' }} extras: ${{ matrix.plugins == 'all' }} docs: true + html: false tests: true gcc-ver: ${{ matrix.gcc }} secrets: inherit diff --git a/CMakeLists.txt b/CMakeLists.txt index d3db43a6c..4e0e30f44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ else(CMAKE_CONFIGURATION_TYPES) endif(CMAKE_CONFIGURATION_TYPES) option(BUILD_DOCS "Choose whether to build the documentation (requires python and Sphinx)." OFF) +option(BUILD_DOCS_NO_HTML "Don't build the HTML docs, only the in-game docs." OFF) option(REMOVE_SYMBOLS_FROM_DF_STUBS "Remove debug symbols from DF stubs. (Reduces libdfhack size to about half but removes a few useful symbols)" ON) macro(CHECK_GCC compiler_path) @@ -468,7 +469,14 @@ if(BUILD_DOCS) "${CMAKE_CURRENT_SOURCE_DIR}/conf.py" ) - set(SPHINX_OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/docs/html/.buildinfo") + if(BUILD_DOCS_NO_HTML) + set(SPHINX_OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/docs/text/index.txt") + set(SPHINX_BUILD_TARGETS text) + else() + set(SPHINX_OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/docs/html/.buildinfo") + set(SPHINX_BUILD_TARGETS html text) + endif() + set_property( DIRECTORY PROPERTY ADDITIONAL_CLEAN_FILES TRUE "${CMAKE_CURRENT_SOURCE_DIR}/docs/changelogs" @@ -485,9 +493,10 @@ if(BUILD_DOCS) "${CMAKE_BINARY_DIR}/docs/text" "${CMAKE_BINARY_DIR}/docs/xml" ) + add_custom_command(OUTPUT ${SPHINX_OUTPUT} COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/docs/build.py" - html text --sphinx="${SPHINX_EXECUTABLE}" -- -q -W + ${SPHINX_BUILD_TARGETS} --sphinx="${SPHINX_EXECUTABLE}" -- -q -W DEPENDS ${SPHINX_DEPS} COMMENT "Building documentation with Sphinx" ) @@ -500,10 +509,12 @@ if(BUILD_DOCS) add_custom_command(TARGET dfhack_docs POST_BUILD COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_OUTPUT}) - install(DIRECTORY ${dfhack_SOURCE_DIR}/docs/html/ - DESTINATION ${DFHACK_USERDOC_DESTINATION}/docs - FILES_MATCHING PATTERN "*" - PATTERN html/_sources EXCLUDE) + if(NOT BUILD_DOCS_NO_HTML) + install(DIRECTORY ${dfhack_SOURCE_DIR}/docs/html/ + DESTINATION ${DFHACK_USERDOC_DESTINATION}/docs + FILES_MATCHING PATTERN "*" + PATTERN html/_sources EXCLUDE) + endif() install(DIRECTORY ${dfhack_SOURCE_DIR}/docs/text/ DESTINATION ${DFHACK_USERDOC_DESTINATION}/docs) install(FILES docs/changelogs/news.rst docs/changelogs/news-dev.rst DESTINATION ${DFHACK_USERDOC_DESTINATION}) From 5e1854edae5415bc154eb680f2cfedeab18d3120 Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Sat, 5 Aug 2023 07:11:36 +0000 Subject: [PATCH 4/6] Auto-update submodules library/xml: master scripts: master --- library/xml | 2 +- scripts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/xml b/library/xml index a5405ed29..88e95e3b9 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit a5405ed296a97fb64b272986b850b289f2064ac1 +Subproject commit 88e95e3b9282b83d5134839f3bd7fc021f0ba53e diff --git a/scripts b/scripts index 8bd85f707..b0ac91f37 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 8bd85f7078bf38788825507df2271986454ad74a +Subproject commit b0ac91f37fe85ac2538caff3d507c861e99dc803 From 9552d145b6782030f5e445997415ed9f798916eb Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sat, 5 Aug 2023 00:56:16 -0700 Subject: [PATCH 5/6] clean up steam deployment code --- .github/workflows/steam-deploy.yml | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/.github/workflows/steam-deploy.yml b/.github/workflows/steam-deploy.yml index 5b14d0bc8..70d061221 100644 --- a/.github/workflows/steam-deploy.yml +++ b/.github/workflows/steam-deploy.yml @@ -68,23 +68,10 @@ jobs: runs-on: ubuntu-latest concurrency: steam steps: - - name: Set env + - name: Get tag run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Stage common depot files + - name: Stage depot files uses: actions/download-artifact@v3 - with: - name: common-depot - path: common - - name: Stage win64 depot files - uses: actions/download-artifact@v3 - with: - name: win64-depot - path: win64 - - name: Stage linux64 depot files - uses: actions/download-artifact@v3 - with: - name: linux64-depot - path: linux64 - name: Steam deploy uses: game-ci/steam-deploy@v3 with: @@ -93,7 +80,7 @@ jobs: appId: 2346660 buildDescription: ${{ github.event.inputs && github.event.inputs.version || env.TAG }} rootPath: . - depot1Path: common - depot2Path: win64 - depot3Path: linux64 + depot1Path: common-depot + depot2Path: win64-depot + depot3Path: linux64-depot releaseBranch: ${{ github.event.inputs && github.event.inputs.release_channel || 'staging' }} From 6357aa2419416b82e51218a7be58d1dd49ef91da Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sat, 5 Aug 2023 00:58:09 -0700 Subject: [PATCH 6/6] factor out release package logic --- .github/workflows/build.yml | 22 ++---------- .github/workflows/github-release.yml | 40 ++++------------------ .github/workflows/package.yml | 51 ++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/package.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 051fc55b7..3f2017324 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,26 +7,10 @@ jobs: uses: ./.github/workflows/test.yml secrets: inherit - package-linux: - name: Linux package - uses: ./.github/workflows/build-linux.yml - with: - artifact-name: dfhack-linux64-build - append-date-and-hash: true - cache-id: release - stonesense: true - docs: true - secrets: inherit - - package-win64: - name: Win64 package - uses: ./.github/workflows/build-windows.yml + package: + uses: ./.github/workflows/package.yml with: - artifact-name: dfhack-win64-build - append-date-and-hash: true - cache-id: release - stonesense: true - docs: true + dfhack_ref: ${{ github.ref }} secrets: inherit docs: diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml index 56bc26702..2d8e55335 100644 --- a/.github/workflows/github-release.yml +++ b/.github/workflows/github-release.yml @@ -12,36 +12,18 @@ on: required: true jobs: - package-win64: - name: Build win64 release - uses: ./.github/workflows/build-windows.yml + package: + uses: ./.github/workflows/package.yml with: - artifact-name: win64-release dfhack_ref: ${{ github.event.inputs && github.event.inputs.ref || github.event.ref }} - cache-id: release + append-date-and-hash: false cache-readonly: true - stonesense: true - docs: true launchdf: true secrets: inherit - package-linux64: - name: Build linux64 release - uses: ./.github/workflows/build-linux.yml - with: - artifact-name: linux64-release - dfhack_ref: ${{ github.event.inputs && github.event.inputs.ref || github.event.ref }} - cache-id: release - cache-readonly: true - stonesense: true - docs: true - secrets: inherit - create-update-release: name: Draft GitHub release - needs: - - package-win64 - - package-linux64 + needs: package runs-on: ubuntu-latest permissions: contents: write @@ -63,23 +45,15 @@ jobs: tail -n $((CHANGELOG_LINES - 3)) docs/changelogs/${{ steps.gettag.outputs.name }}-github.txt >> release_body.md tail -n 2 .github/release_template.md >> release_body.md cat release_body.md - - name: Stage win64 release + - name: Stage release uses: actions/download-artifact@v3 - with: - name: win64-release - path: win64 - name: Create win64 release archive run: | - cd win64 + cd dfhack-windows64-build zip -r ../dfhack-${{ steps.gettag.outputs.name }}-Windows-64bit.zip . - - name: Stage linux64 release - uses: actions/download-artifact@v3 - with: - name: linux64-release - path: linux64 - name: Create linux64 release archive run: | - cd linux64 + cd dfhack-linux64-build tar cjf ../dfhack-${{ steps.gettag.outputs.name }}-Linux-64bit.tar.bz2 . - name: Create or update GitHub release uses: ncipollo/release-action@v1 diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 000000000..eba2f4f71 --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,51 @@ +name: Package + +on: + workflow_call: + inputs: + dfhack_ref: + type: string + scripts_ref: + type: string + structures_ref: + type: string + append-date-and-hash: + type: boolean + default: true + cache-readonly: + type: boolean + default: false + launchdf: + type: boolean + default: false + +jobs: + package-win64: + name: Windows + uses: ./.github/workflows/build-windows.yml + with: + dfhack_ref: ${{ inputs.dfhack_ref }} + scripts_ref: ${{ inputs.scripts_ref }} + structures_ref: ${{ inputs.structures_ref }} + artifact-name: dfhack-windows64-build + append-date-and-hash: ${{ inputs.append-date-and-hash }} + cache-id: release + cache-readonly: ${{ inputs.cache-readonly }} + stonesense: true + docs: true + secrets: inherit + + package-linux: + name: Linux + uses: ./.github/workflows/build-linux.yml + with: + dfhack_ref: ${{ inputs.dfhack_ref }} + scripts_ref: ${{ inputs.scripts_ref }} + structures_ref: ${{ inputs.structures_ref }} + artifact-name: dfhack-linux64-build + append-date-and-hash: ${{ inputs.append-date-and-hash }} + cache-id: release + cache-readonly: ${{ inputs.cache-readonly }} + stonesense: true + docs: true + secrets: inherit