diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d547f8..51c9833 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,10 @@ jobs: # Audit the selected tree shipped in source archives. Full repository # history auditing is available separately with --history. - name: Verify source export - run: python3 tools/public_release/check_public_tree.py --root . + run: | + python3 tools/public_release/check_public_tree.py --root . + python3 tools/ci/test_build_runnable_tests.py + python3 tools/package/test_verify_ci_release.py - name: Set up MSVC x64 if: runner.os == 'Windows' uses: ilammy/msvc-dev-cmd@a102174a2b586eec2ea151a69e6fd14404a8ce7c # v1.13.0 @@ -64,10 +67,20 @@ jobs: run: | test "$(uname -m)" = arm64 cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -DBMH_DATA= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - - name: Build every target - run: cmake --build build --config Release --parallel 2 + - name: Build products and every runnable test + run: python3 tools/ci/build_runnable_tests.py --build build --config Release --parallel 2 - name: Run synthetic tests and report data tests as skipped run: ctest --test-dir build -C Release --output-on-failure --output-junit test-results.xml + - name: Verify product versions + shell: python + run: | + import pathlib, subprocess, sys + build = pathlib.Path('build').resolve() + version = (build / 'product-version.txt').read_text().strip() + suffix = '.exe' if sys.platform == 'win32' else '' + cli = subprocess.run([str(build / ('openbmh_cli' + suffix)), '--version'], check=True, capture_output=True, text=True) + assert cli.stdout.strip() == 'OpenBMH console ' + version + subprocess.run([str(build / ('OpenBMH' + suffix)), '--version'], check=True) - name: Package products and licenses run: python3 tools/package/make_package.py --build build --out dist --platform ${{ matrix.platform }} - name: Package corresponding source and pinned dependencies diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f1da2d5..620b881 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-3.0-only -name: Prepare release packages +name: Prepare verified release on: push: @@ -7,34 +7,59 @@ on: permissions: contents: read + actions: read jobs: - build: - uses: ./.github/workflows/ci.yml draft: - needs: build runs-on: ubuntu-24.04 permissions: contents: write + actions: read steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false fetch-depth: 0 + - name: Locate successful CI for this exact revision + id: ci + env: + GH_TOKEN: ${{ github.token }} + EXPECTED_SHA: ${{ github.sha }} + run: | + gh api "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs?status=success&event=push&per_page=100" > ci-runs.json + python3 - <<'PY' + import json, os + runs = json.load(open('ci-runs.json'))['workflow_runs'] + matches = [r for r in runs if r['head_sha'] == os.environ['EXPECTED_SHA'] and + r['conclusion'] == 'success' and r['event'] == 'push' and + r['head_repository']['full_name'].lower() == os.environ['GITHUB_REPOSITORY'].lower()] + if not matches: + raise SystemExit('Run the full CI successfully for this revision before tagging a release') + with open(os.environ['GITHUB_OUTPUT'], 'a') as output: + output.write('run_id=' + str(matches[0]['id']) + '\n') + PY - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: + github-token: ${{ github.token }} + run-id: ${{ steps.ci.outputs.run_id }} pattern: OpenBMH-* path: dist merge-multiple: true + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + with: + github-token: ${{ github.token }} + run-id: ${{ steps.ci.outputs.run_id }} + pattern: tests-* + path: test-reports + - name: Verify archives, corresponding source and platform reports + env: + RELEASE_TAG: ${{ github.ref_name }} + CI_RUN: ${{ steps.ci.outputs.run_id }} + run: | + python3 tools/package/verify_ci_release.py --dist dist --reports test-reports --tag "$RELEASE_TAG" --source-sha "$GITHUB_SHA" --ci-run "$CI_RUN" --repository "$GITHUB_REPOSITORY" - name: Create draft for review env: GH_TOKEN: ${{ github.token }} RELEASE_TAG: ${{ github.ref_name }} run: | - for package in dist/*.zip; do - case "$(basename "$package")" in - OpenBMH-${RELEASE_TAG#v}-*.zip) ;; - *) echo "Release tag and package version differ" >&2; exit 1 ;; - esac - done - gh release create "$RELEASE_TAG" dist/*.zip --draft --verify-tag --title "OpenBMH $RELEASE_TAG" --notes-file docs/release/1.0/RELEASE_NOTES.md + gh release create "$RELEASE_TAG" dist/*.zip dist/SHA256SUMS dist/QA-REPORT.json --draft --verify-tag --title "OpenBMH $RELEASE_TAG" --notes-file docs/release/1.0/RELEASE_NOTES.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 1db0830..2a3dd78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,15 @@ # SPDX-License-Identifier: GPL-3.0-only cmake_minimum_required(VERSION 3.24) project(OpenBMH VERSION 1.0.0 LANGUAGES CXX C) -set(OPENBMH_PRERELEASE "rc.1" CACHE STRING "Prerelease identifier; empty for final release") +set(OPENBMH_PRERELEASE "" CACHE STRING "Prerelease identifier; empty for final release") set(OPENBMH_PRODUCT_VERSION "${PROJECT_VERSION}") if(OPENBMH_PRERELEASE) string(APPEND OPENBMH_PRODUCT_VERSION "-${OPENBMH_PRERELEASE}") endif() file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/product-version.txt" CONTENT "${OPENBMH_PRODUCT_VERSION}\n") # the one place of the version: --version of both programs and the window title (src/version.hpp) -add_compile_definitions(OPENBMH_VERSION="${OPENBMH_PRODUCT_VERSION}") +file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/generated/openbmh_build_version.hpp" + CONTENT "// SPDX-License-Identifier: GPL-3.0-only\n#pragma once\n#define OPENBMH_VERSION \"${OPENBMH_PRODUCT_VERSION}\"\n") set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -447,6 +448,7 @@ target_link_libraries(openbmh_play PRIVATE bmhui bmhlaunch_dialog openbmh_audio # a game without a console window on double-click (SDL2main provides WinMain); started from a # console it attaches to that one for --version, --help and start errors (src/app/main.cpp) set_target_properties(openbmh_play PROPERTIES WIN32_EXECUTABLE TRUE OUTPUT_NAME OpenBMH) +target_include_directories(openbmh_play PRIVATE "${CMAKE_BINARY_DIR}/generated") if(MSVC) target_compile_options(openbmh_play PRIVATE /utf-8) # App sources also compile in headless tests/helpers without target /utf-8. @@ -626,6 +628,7 @@ add_executable(openbmh_cli src/cli/seat_hub.cpp src/cli/json.cpp ${BMH_APP_SESSION_SOURCE}) +target_include_directories(openbmh_cli PRIVATE "${CMAKE_BINARY_DIR}/generated") target_link_libraries(openbmh_cli PRIVATE bmhui bmhlaunch) if(WIN32) target_link_libraries(openbmh_cli PRIVATE ws2_32) # --listen (Winsock) @@ -1120,3 +1123,7 @@ add_executable(season_player_reset_tests tests/season_player_reset_tests.cpp) target_link_libraries(season_player_reset_tests PRIVATE bmhcore) add_test(NAME season_player_reset_tests COMMAND season_player_reset_tests) set_tests_properties(season_player_reset_tests PROPERTIES TIMEOUT 10) + +add_executable(lineup_foreign_limit_tests tests/lineup_foreign_limit_tests.cpp) +target_link_libraries(lineup_foreign_limit_tests PRIVATE bmhcore) +add_test(NAME lineup_foreign_limit_tests COMMAND lineup_foreign_limit_tests) diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 632d54a..e75d656 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -50,3 +50,14 @@ build/openbmh_cli --console --data "path/to/game" --saves "path/to/saves" --seed ``` For redistribution, include [LICENSE](../LICENSE), [THIRD_PARTY_NOTICES.md](../THIRD_PARTY_NOTICES.md), the full texts in [licenses/](licenses/README.md), and the corresponding source and build information required by the applicable licenses. Inspect the actual libraries in each platform package; static SDL2 alone does not establish that every dependency is static. + +## Build the data-free CI subset + +`cmake --build build` compiles every development helper and test. With no private integration data configured, CI builds both products and every executable actually referenced by CTest instead: + +```sh +python3 tools/ci/build_runnable_tests.py --build build --config Release --parallel 2 +ctest --test-dir build -C Release --output-on-failure +``` + +Tests whose inputs are unavailable still report a skip through the normal optional-data helper; they are not counted as passes. Supplying integration data during configuration causes their real programs to enter this build subset automatically. Source-export and build-discovery checks run separately in CI. diff --git a/docs/COMPATIBILITY.md b/docs/COMPATIBILITY.md index 29c7ee2..0ea0275 100644 --- a/docs/COMPATIBILITY.md +++ b/docs/COMPATIBILITY.md @@ -37,3 +37,7 @@ The supplied edition controls whether foreign league clubs use individual original crests or the original neutral crest. OpenBMH recognizes the verified Diamond 3.7 drawing gate and uses its database/save selectors and W atlases. Older drawing gates retain their own behaviour; no external crest pack is needed. + +The automatic lineup installs the supplied foreign-player rule switch alongside the career tables. Where enabled, it restores the original three/two-player limit, reserve swaps with board-coordinate preservation and the short-lineup outcome when domestic reserves are unavailable. This does not consume additional random draws. + +New careers correct the original all-zero EM qualification placeholders to the original national-team placeholders. Supplied nonzero seeds and restored savegame state are not rewritten by this initialization. diff --git a/docs/DIFFERENCES.md b/docs/DIFFERENCES.md index 46791c9..ca8a619 100644 --- a/docs/DIFFERENCES.md +++ b/docs/DIFFERENCES.md @@ -12,12 +12,13 @@ describe deliberate changes; they are not a list of every known compatibility li - [src/game/desk_actions.cpp](../src/game/desk_actions.cpp): uses the supported transfer-fee arithmetic and designated set-piece fields. - [src/game/desk_actions.hpp](../src/game/desk_actions.hpp): supports designated set-piece records and the supported transfer-editor rules. - [src/game/highscore.cpp](../src/game/highscore.cpp): reads the supported edition-specific high-score format from the loaded image. -- [src/game/lineup.cpp](../src/game/lineup.cpp): disables the foreign-player limit in the supported rule profile. -- [src/game/lineup.hpp](../src/game/lineup.hpp): disables the foreign-player limit and supports owner-bound designated set-piece selection. +- [src/game/lineup.hpp](../src/game/lineup.hpp): supports owner-bound designated set-piece selection. - [src/game/match.hpp](../src/game/match.hpp): uses the enhanced injury selection and suspension rules. - [src/game/match_engine.cpp](../src/game/match_engine.cpp): supports designated set-piece takers, the enhanced injury tables, and the extended suspension fields. - [src/game/season.cpp](../src/game/season.cpp): retains the enhanced academy player-generation strength bands with monthly youth budgets. +- [src/game/season.cpp](../src/game/season.cpp): age/retire each player once, even when a temporary offer row references his club slot or regeneration moves him to a later free-agent slot. - [src/game/season.cpp](../src/game/season.cpp): includes transfer-market players in retirement so the five-bit age cannot wrap to 16. +- [src/game/season.cpp](../src/game/season.cpp): initializes the empty EM qualifier seeds with national teams, preventing club zero from entering the EM. - [src/game/season.hpp](../src/game/season.hpp): retains the enhanced academy player-generation strength bands with monthly youth budgets. - [src/game/state.hpp](../src/game/state.hpp): retains designated set-piece selections in the supported manager-record extension. - [src/game/week.cpp](../src/game/week.cpp): uses the enhanced training rules: focus strength is at least five below its target, and completed skills rotate to another focus. diff --git a/docs/release/1.0/RELEASE_NOTES.md b/docs/release/1.0/RELEASE_NOTES.md index c13b8b2..2e5ea60 100644 --- a/docs/release/1.0/RELEASE_NOTES.md +++ b/docs/release/1.0/RELEASE_NOTES.md @@ -1,11 +1,17 @@ -# OpenBMH 1.0 release candidate +# OpenBMH 1.0.0 Classic direct-installation runtime restored from v0.1.2. The game executable is OpenBMH / OpenBMH.exe; openbmh_cli remains available. Reviewed backports include host filename/path handling, explicit quit confirmation, original message text installation in standalone tools, and clearing the calendar replay flag after undoing a reschedule. German CD-compatible BMH and verified Diamond editions are the release targets. Football Limited remains experimental; the old floppy executable is unsupported. -This candidate is under compatibility validation, especially edition-dependent rules and environment behaviour. No complete platform or original-game acceptance is claimed before its recorded tests pass. +This community release focuses on the original game. See VALIDATION.md for the scope and limits of its checks. Build/test reports do not establish complete bit-for-bit parity with every original edition. Diamond 3.7 foreign league crests use the supplied edition's original drawing gate, database selectors and W sheets. Older editions retain their original neutral foreign-club crest. Transfer-market players now enter the season-boundary retirement process, preventing the five-bit age from wrapping from 47 to 16. Relocated free agents no longer leave a duplicate in their old market slot. Young club players retain their existing random-draw count. + +The automatic lineup reads the original foreign-player limit switch: enabled editions enforce three foreign starters in domestic clubs and two in the foreign leagues, with original reserve replacement and partial-lineup handling. Editions that disable this rule retain unrestricted selection. New careers also initialize the original empty EM qualification placeholders with national-team IDs; existing nonzero seeds and loaded savegames are preserved. + +Known limits: Football Limited remains experimental, the floppy executable is unsupported, and intentional implementation differences remain listed in docs/DIFFERENCES.md. The supplied original-defect catalogue is an ongoing compatibility reference, not a claim that all its entries have received independent runtime acceptance. + +The season reset processes each player only once, including temporary offer references to an active club player. This prevents double ageing and regeneration of a still-owned player into a second club. The correction is covered by a synthetic cached-offer regression and long runs through eleven to twelve season-end desks. diff --git a/docs/release/1.0/VALIDATION.md b/docs/release/1.0/VALIDATION.md index 114aad6..882d61f 100644 --- a/docs/release/1.0/VALIDATION.md +++ b/docs/release/1.0/VALIDATION.md @@ -1,9 +1,9 @@ # Classic 1.0 candidate validation -Status: implementation candidate, not final-release acceptance. +Scope: recorded automated/original-data checks. Exact final source revision and native platform build records accompany the published release. - Linux x64 Release build: all targets compiled. -- CTest: 33 passed, 157 skipped, zero failures (190 registered tests). Skips require separately configured original-data or save fixtures; they are not acceptance passes. +- CTest: 34 passed, 157 skipped, zero failures (191 registered tests). Skips require separately configured original-data or save fixtures; they are not acceptance passes. - Synthetic tests cover unchanged executable image loading, nine original strength ranges, atomic rejection of malformed ranges, unsupported environment guards, and legacy/extended/truncated crest gates. - Public source scan: zero findings; generated differences catalogue matches source markers. - Version output: both GUI and console identify 1.0.0-rc.1. @@ -19,3 +19,15 @@ Source archives contain the audited current tree. The optional full-history audi Twenty-six additional private-data checks passed across BMH CD and Diamond 3.6/3.7: exact loaded fixture tables, manager selection, standard dialogs, training camps, tactics, banking, settings and player cards. The Diamond 3.6 two-manager fixture also passed the human-buyer transfer and rescheduling suites. A currency-format fixture had assumed the Diamond resort price for all German editions; its fixed-price check now uses an explicit synthetic price, and the CD test passes without changing game data or product prices. These are automated render/interaction and engine checks, not a claim of complete interactive playthroughs. The market-player retirement regression failed before the correction with an age wrap from 47 to 16 and passed afterward. It checks market boundaries, unique relocation, unaffected extra slots, new-career setup and unchanged random draw counts for a young club player. + +## Additional edition rules + +Targeted synthetic tests pass for the enabled/disabled foreign-player switch, domestic and foreign clubs, human assistant board and card-row movement, reserve shortages and switching back to an unrestricted edition. Separate season-boundary tests pass for zero EM placeholders becoming national teams and existing nonzero seeds remaining unchanged. Final full-build/platform acceptance for these additions is recorded with the release artifacts. + +Long-run diagnostics with seed 4711 and the existing explicit contract-renewal policy reached 120 turns and two season-end desks in each of the three German data editions. Diamond 3.6/3.7 returned success. Original CD exceeded the simulator's statistical high-score threshold (two ordinary results above twelve goals); it is recorded as a QA finding, not hidden or counted as a successful simulation. The earlier no-presenter runs stopped at a contract expiry; enabling the existing opt-in presenter resolved that harness limitation without changing gameplay code. + +## Extended season regression + +After the final lineup, qualification and once-per-player season-reset corrections, each German edition completed 600 turns using seed 4711. Original CD reached twelve season-end desks; Diamond 3.6 and 3.7 reached eleven each. With the existing explicit contract-renewal and advertising policies enabled, all three simulator runs returned success, with no duplicate club players or other invariant failures. With contract renewals alone, all three still completed 600 turns without duplicate club players; only the test policy's excessive-debt warning remained. The latter is not presented as a successful financial strategy. + +The duplicate-player defect was reproduced and captured before correction: a temporary offer referenced a player already owned by a club, then the extended market-retirement pass regenerated that player a second time. Frozen private before/after saves and a cached-reference regression support the correction. Save-envelope diagnostics use a separate RNG and do not consume either gameplay stream. diff --git a/src/game/career.cpp b/src/game/career.cpp index e8b32e4..00f622d 100644 --- a/src/game/career.cpp +++ b/src/game/career.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only #include "formats/executable_layout.hpp" #include "game/career.hpp" +#include "game/lineup.hpp" #include @@ -38,6 +39,7 @@ void install_career_rules(const LeImage& exe) { if (next[league][0] > next[league][1] || next[league][1] > 99) throw FormatError("career: unsupported original league strength range"); } + install_lineup_rules(exe); for (int league = 0; league < 9; ++league) for (int bound = 0; bound < 2; ++bound) kLeagueStrength[league][bound] = next[league][bound]; } diff --git a/src/game/lineup.cpp b/src/game/lineup.cpp index 1dea703..9152c95 100644 --- a/src/game/lineup.cpp +++ b/src/game/lineup.cpp @@ -1,6 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-only #include "formats/executable_layout.hpp" #include "game/lineup.hpp" +#include "formats/le.hpp" +#include "game/match.hpp" +#include "game/weekly.hpp" #include #include @@ -10,6 +13,7 @@ namespace bmh { namespace { +bool original_foreign_limit_enabled = false; // Position type by formation depth x (table at layout field). constexpr int8_t kTypeByDepth[24] = {0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 0, 1, 2, 2}; @@ -317,6 +321,10 @@ bool save_pitch_formation_source(GameState& g, int manager_slot, int runtime_clu } } +void install_lineup_rules(const LeImage& exe) { + original_foreign_limit_enabled = exe.u8(layout::ForeignPlayerLimitEnabled) != 0; +} + static void auto_lineup_impl(GameState& g, int team, int mode, int manager) { if (team >= 138 && team != kNoTeam) return; // teams without squads if (g.lineups_frozen) return; // LineupRuntimeField (the season change) @@ -574,8 +582,52 @@ static void auto_lineup_impl(GameState& g, int team, int mode, int manager) { break; } } - // OpenBMH deviates from the original: disables the foreign-player limit in the supported rule profile. -// (foreign-player limit ForeignPlayerLimitEnabled is off in the supported rule profile) + if (original_foreign_limit_enabled) { + const int country = team_region(team) & 0xff; + const int allowed = 3 - int(country != 0); + std::vector foreign_rows, foreign_roles; + for (int row = 0; row < 11; ++row) { + const int id = g.squad_slots.at(range.first + row) & 0x0fff; + if (id != 0x0fff && nationality(g, id) != country) { + foreign_rows.push_back(row); + foreign_roles.push_back(g.players.at(id).position()); + } + } + int tolerance = 0; + for (int attempt = 0; foreign_rows.size() > size_t(allowed) && attempt < 200; ++attempt) { + ++tolerance; + if (tolerance > 100) { + // No suitable domestic reserve: retain the original short-lineup + // outcome rather than fielding more foreign players than allowed. + g.squad_slots.at(range.first + foreign_rows.back()) &= 0x1fff; + foreign_rows.pop_back(); foreign_roles.pop_back(); + continue; + } + for (int row = 11; row < players && value[row] != kUnavailable; ++row) { + const int id = g.squad_slots.at(range.first + row) & 0x0fff; + if (id == 0x0fff || nationality(g, id) != country) continue; + const int role = g.players.at(id).position(); + const int replaced_role = foreign_roles.back(); + if ((role == 0 && replaced_role != 0 && tolerance <= 7) || + std::abs(role - replaced_role) >= tolerance) continue; + const int field = foreign_rows.back(); + foreign_rows.pop_back(); foreign_roles.pop_back(); + auto& incoming = g.squad_slots.at(range.first + row); + auto& outgoing = g.squad_slots.at(range.first + field); + incoming = uint16_t((incoming & 0x1fff) | 0x8000); + outgoing = uint16_t((outgoing & 0x1fff) | (row < 17 ? 0x4000 : 0)); + std::swap(incoming, outgoing); + std::swap(value[row], value[field]); + if (manager >= 0) { + std::swap_ranges(board(row), board(row) + 0x58, board(field)); + std::swap(board(row)[0x41], board(field)[0x41]); + std::swap(board(row)[0x42], board(field)[0x42]); + } + tolerance = 0; + if (foreign_rows.size() <= size_t(allowed)) break; + } + } + } // After a full line-up every player in the eleven or on the bench notes his squad slot // (relative to the squad start) in bits 0-4 of his card word (*PlayerCards). if (!first_eleven_only && !g.player_cards.empty()) diff --git a/src/game/lineup.hpp b/src/game/lineup.hpp index ad72219..6c0c57b 100644 --- a/src/game/lineup.hpp +++ b/src/game/lineup.hpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-only #pragma once -// OpenBMH deviates from the original: disables the foreign-player limit and supports owner-bound designated set-piece selection. +// OpenBMH deviates from the original: supports owner-bound designated set-piece selection. // Automatic line-up of computer teams, port of Int2. // // The squad of a team is a run of squad slots (squad_range). The first 11 slots are the @@ -21,7 +21,7 @@ // The chosen player is swapped into slot p and flagged 0x8000 (slots 0-10) or 0x4000. // // Ported: assistant training-camp familiarity penalty and detailed position scoring at -// difficulty >= 6. The foreign-player limit (ForeignPlayerLimitEnabled) is off in supported rule profile. +// difficulty >= 6. The supplied edition controls the original foreign-player limit. #include #include @@ -30,6 +30,10 @@ #include "game/state.hpp" namespace bmh { +class LeImage; +// Install the supplied edition's original automatic-lineup rule switch. +void install_lineup_rules(const LeImage& exe); + // Games: in-place quicksort (Hoare partition, middle element as pivot) of `keys` // descending (ascending if `ascending`), comparing as unsigned 32-bit, moving `items` @@ -93,7 +97,7 @@ bool save_pitch_formation_source(GameState& g, int manager_slot, int runtime_clu int formation, uint8_t expected_weights, const std::array& formation_positions); -// OpenBMH deviates from the original: disables the foreign-player limit and supports owner-bound designated set-piece selection. +// OpenBMH deviates from the original: supports owner-bound designated set-piece selection. // supported rule profile NormalizePitchSetPieceSource/NormalizePitchSetPieceSource3/NormalizePitchSetPieceSource2/NormalizePitchSetPieceSource4: deterministic, owner-bound // set-piece presentation state. Stored takers are player_id+1; zero is AUTO. bool normalize_pitch_set_piece_source(GameState& g, int manager_slot, int runtime_club); diff --git a/src/game/season.cpp b/src/game/season.cpp index 6d0e4da..739edeb 100644 --- a/src/game/season.cpp +++ b/src/game/season.cpp @@ -1167,10 +1167,16 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe uint8_t count = 0xff; // local_20 int8_t owner = -1; // local_24: the club's human manager size_t board_first = 0; // local_3c + std::vector processed(g.players.size(), false); for (int s = 0; s < 0xc00 && !report.unsupported; s++) { for (;;) { const int player = g.squad_slots.at(size_t(s)) & 0xFFF; if (player == 0xFFF) break; + // OpenBMH deviates from the original: age/retire each player + // once, even when a temporary offer row references his club + // slot or regeneration moves him to a later free-agent slot. + if (processed.at(size_t(player))) break; + processed.at(size_t(player)) = true; const int team = slot_team(s); if (team != int(last_team)) { // (-1 for the pool never equals 0xFFFF) count = 0xff; @@ -1643,6 +1649,16 @@ SeasonTransitionOutcome season_transition(GameState& g, GameRandom& game, Watcom namespace bmh { +void initialize_european_qualification_seed(GameState& g) { + constexpr uint32_t entry = layout::CupTable + 14 * 0x28; + if (g.memory.u16(entry + 0x22) == 0 && g.memory.u16(entry + 0x24) == 0) { + // OpenBMH deviates from the original: initializes the empty EM qualifier + // seeds with national teams, preventing club zero from entering the EM. + g.memory.set16(entry + 0x22, 357); + g.memory.set16(entry + 0x24, 358); + } +} + bool career_season_setup(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteReport& report, const std::function& pause, const SeasonCupDrawHook& cup_draw) { @@ -1662,6 +1678,7 @@ bool career_season_setup(GameState& g, GameRandom& game, WatcomRandom& rand, Min mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField5, uint16_t(first_small + 0x1f)); mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField4, uint16_t(first_small + 0x13)); mem.set16(::bmh::layout::Season_CareerSeasonSetup_RuntimeField3, uint16_t(foreign + 1)); + initialize_european_qualification_seed(g); mem.set16(::bmh::layout::Career_CompetitionPointersEnglish_ExecutableField28, 0); mem.set16(::bmh::layout::Cup_AdvanceCup_RuntimeField6, 0); mem.set16(::bmh::layout::Cup_AdvanceCup_RuntimeField5, 7); diff --git a/src/game/season.hpp b/src/game/season.hpp index 06f0808..1e79995 100644 --- a/src/game/season.hpp +++ b/src/game/season.hpp @@ -187,6 +187,10 @@ void cup_group_overview_effects(GameState& g, int group_index); // LeagueName: the name of a league below 5 (with its letter, e.g. for the third divisions). std::string league_name(const GameState& g, int league); +// New careers: fill the original uninitialized EM qualification placeholders; +// preserve any nonzero seeds supplied by the installation. +void initialize_european_qualification_seed(GameState& g); + // Season boundary: reset manager boards, age/retire players and clear seasonal // histories. Kept separate from cup draws, accounts and calendar advancement. void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteReport& report); diff --git a/src/version.hpp b/src/version.hpp index ef4f3f6..53e49b8 100644 --- a/src/version.hpp +++ b/src/version.hpp @@ -1,9 +1,13 @@ // SPDX-License-Identifier: GPL-3.0-only #pragma once -// The OpenBMH version. CMake sets OPENBMH_VERSION from project(... VERSION ...) in the top -// CMakeLists.txt - the one place to change it; this fallback only serves other builds. +// Only the product entry points include the generated version, so changing a +// release number does not rebuild the game, test suites or third-party code. #ifndef OPENBMH_VERSION -#define OPENBMH_VERSION "0.1.0-dev" +#if __has_include("openbmh_build_version.hpp") +#include "openbmh_build_version.hpp" +#else +#define OPENBMH_VERSION "development" +#endif #endif namespace bmh { diff --git a/tests/lineup_foreign_limit_tests.cpp b/tests/lineup_foreign_limit_tests.cpp new file mode 100644 index 0000000..2496742 --- /dev/null +++ b/tests/lineup_foreign_limit_tests.cpp @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-3.0-only +#include "game/lineup.hpp" +#include "game/match.hpp" +#include "game/weekly.hpp" +#include "formats/le.hpp" +#include "formats/executable_layout.hpp" +#include +#include + +namespace { +void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); } +void enabled(bool value) { + auto exe = bmh::LeImage::from_bytes(bmh::layout::ForeignPlayerLimitEnabled, bmh::Bytes{uint8_t(value)}); + bmh::install_lineup_rules(exe); +} +bmh::GameState fixture(int team, bool human = false, bool all_foreign = false) { + bmh::GameState g; + const auto range = bmh::squad_range(team); + g.squad_slots.assign(3096, 0xfff); + g.players.resize(range.count); g.player_bonus.resize(range.count); g.player_cards.resize(range.count, 0x9a00); + g.team_flags.resize(138); g.formations.resize(0x160); + g.formations[0] = 0; + for (int p = 1; p < 11; ++p) g.formations[size_t(p)] = 7; + const int country = bmh::team_region(team); + for (size_t i = 0; i < range.count; ++i) { + g.squad_slots[range.first+i] = uint16_t(i); + auto& player = g.players[i]; + const int strength = i < 6 ? 95 : 60; + player.w35c = 60u | uint32_t(strength) << 7 | uint32_t(strength) << 14; + player.w364 = i == 0 || i == 11 ? 0 : 1; + player.w368 = uint32_t(i < 6 || all_foreign ? country + 1 : country) << 27; + } + if (human) { + g.manager_teams = {team}; g.manager_options = {1,0,0,0,0}; + g.manager_records.resize(0xb0c); g.tactics.resize(0x840); + for (size_t i = 0; i < range.count; ++i) g.tactics[i*0x58+0x50] = uint8_t(i+1); + } + return g; +} +int foreign_starters(const bmh::GameState& g, int team) { + int count = 0; const auto r = bmh::squad_range(team); + for (int row = 0; row < 11; ++row) { + const auto entry = g.squad_slots[r.first+size_t(row)]; + if ((entry & 0x8000) && bmh::nationality(g, entry & 0xfff) != bmh::team_region(team)) ++count; + } + return count; +} +} +int main() try { + enabled(false); auto unrestricted = fixture(0); bmh::auto_lineup(unrestricted,0,100); + check(foreign_starters(unrestricted,0)==6,"disabled edition changed foreign selection"); + enabled(true); + for (int team : {0,90}) { + auto g = fixture(team); bmh::auto_lineup(g,team,100); + check(foreign_starters(g,team)==(team==0?3:2),"original domestic/foreign league limit not enforced"); + } + auto human = fixture(0,true); bmh::auto_lineup(human,0,100); + check(foreign_starters(human,0)==3,"human assistant ignored original limit"); + for (int row=0;row<24;++row) { + const auto entry=human.squad_slots[size_t(row)];const size_t id=entry&0xfff; + check(human.tactics[size_t(row)*0x58+0x50]==id+1,"player salary board lost during foreign swap"); + if(entry&0xc000)check((human.player_cards[id]&31)==row,"card row index not updated after foreign swap"); + if(row<11)check(human.tactics[size_t(row)*0x58+0x41]==(row?7:0),"formation coordinate moved with replaced player"); + } + auto shortage = fixture(0,false,true); bmh::auto_lineup(shortage,0,100); + check(foreign_starters(shortage,0)==3,"shortage of domestic reserves did not terminate with a legal partial lineup"); + enabled(false); auto restored=fixture(0);bmh::auto_lineup(restored,0,100); + check(restored.squad_slots==unrestricted.squad_slots && restored.player_cards==unrestricted.player_cards, + "switching back to disabled edition did not restore unchanged selection"); + std::cout<<"Original foreign lineup limits, board swaps and edition switching passed\n"; + return 0; +} catch(const std::exception&e){std::cerr< #include #include @@ -29,6 +30,18 @@ void run(bmh::GameState& g, bmh::GameRandom& game, bmh::WatcomRandom& rand) { } } int main() try { + { + auto g = fixture(2928, 20); + constexpr uint32_t entry = bmh::layout::CupTable + 14 * 0x28; + g.memory.set8(entry, 0x7f); + bmh::initialize_european_qualification_seed(g); + check(g.memory.u16(entry + 0x22) == 357 && g.memory.u16(entry + 0x24) == 358 && + g.memory.u8(entry) == 0x7f, "empty EM seeds did not become national teams without changing descriptor data"); + g.memory.set16(entry + 0x22, 361); g.memory.set16(entry + 0x24, 364); + bmh::initialize_european_qualification_seed(g); + check(g.memory.u16(entry + 0x22) == 361 && g.memory.u16(entry + 0x24) == 364, + "existing original national qualification seeds were overwritten"); + } for (const auto [slot, foreign] : {std::pair{2928, false}, {2971, false}, {2972, false}, {3071, true}}) { auto g = fixture(slot, 47, foreign); bmh::GameRandom game(4711); bmh::WatcomRandom rand(815); @@ -49,6 +62,16 @@ int main() try { check(game.calls() == 0 && rand.calls() == 1, "unchanged club ageing consumed additional random draws"); } + { + auto g = fixture(0, 20); + g.squad_slots[2968] = 0; // Cached contract/offer row still references this club player. + bmh::GameRandom game(4711); bmh::WatcomRandom rand(815); + run(g, game, rand); + check(g.players[0].age() == 21 && g.squad_slots[0] == 0 && g.squad_slots[2968] == 0, + "cached offer aged or recycled a player still owned by his club"); + check(game.calls() == 0 && rand.calls() == 1, + "cached offer consumed a second retirement draw for its club player"); + } { auto g = fixture(3072, 47); bmh::GameRandom game(4711); bmh::WatcomRandom rand(815); diff --git a/tests/season_sim.cpp b/tests/season_sim.cpp index 5259708..ede0ad4 100644 --- a/tests/season_sim.cpp +++ b/tests/season_sim.cpp @@ -13,6 +13,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -20,6 +23,7 @@ #include "app/career_session.hpp" #include "game/desk_actions.hpp" +#include "game/save.hpp" #include "game/lineup.hpp" #include "game/matchday.hpp" #include "game/month.hpp" @@ -71,6 +75,37 @@ void check_state(const GameState& g, const std::string& when, Checks& c) { } } +// Optional private investigation: snapshots use their own save-envelope RNG; +// observing a failure never consumes either gameplay stream. +bool capture_duplicate(const GameState& before, const GameState& after, + const std::filesystem::path& directory) { + std::set seen; + int duplicate = -1; + for (size_t slot = 0; slot < 2928 && slot < after.squad_slots.size(); ++slot) { + const int id = after.squad_slots[slot] & 0xfff; + if (id != 0xfff && !seen.insert(id).second) { duplicate = id; break; } + } + if (duplicate < 0) return false; + std::filesystem::create_directories(directory); + WatcomRandom envelope(1); + write_savegame(directory / "before_duplicate.FBM", make_savegame(before, envelope)); + write_savegame(directory / "after_duplicate.FBM", make_savegame(after, envelope)); + std::ofstream report(directory / "duplicate.txt"); + report << "player=" << duplicate << " before_day=" << before.date << " after_day=" << after.date << '\n'; + for (const auto* state : {&before, &after}) { + report << "day=" << state->date << " age=" << state->players.at(size_t(duplicate)).age() << '\n'; + for (size_t slot = 0; slot < state->squad_slots.size(); ++slot) + if ((state->squad_slots[slot] & 0xfff) == duplicate) + report << "slot=" << slot << " team=" << slot_team(int(slot)) << " flags=" << (state->squad_slots[slot] & 0xf000) << '\n'; + for (uint32_t row = 0; row < 200; ++row) { + const auto value = state->memory.u32(layout::Career_RemoveJoinLoans_RuntimeField + row * 4); + if (value && (value & 0xfff) == uint32_t(duplicate)) + report << "loan_row=" << row << " raw=" << value << '\n'; + } + } + return true; +} + // The matchday just played. Cup phase 2 stores the shoot-out goals added to the // match score (legacy routine). The total-12 plausibility check cannot apply to that // combined display score: Original week40_capture.jsonl:241 records 11:10. @@ -150,6 +185,8 @@ int main(int argc, char** argv) { Checks checks; std::string gap; int played = 0, goals = 0, matches = 0, seasons = 0; + const char* duplicate_directory = std::getenv("SIM_DUPLICATE_DIR"); + bool duplicate_captured = false; try { app::CareerSession session(argv[1], argc > 4 ? uint32_t(std::stoul(argv[4])) : 1u); ui::SetupOptions options; // 5 seasons, level 2, one manager, mode III, league and world @@ -305,6 +342,8 @@ int main(int argc, char** argv) { if (offer.status == TransferActionStatus::pending || offer.status == TransferActionStatus::accepted) break; } } + std::optional duplicate_before; + if (duplicate_directory && !duplicate_captured) duplicate_before = g; ui::DeskRequest kickoff; kickoff.kind = ui::DeskRequestKind::advance_turn; kickoff.manager_slot = int(g.memory.u8(::bmh::layout::ActiveManager)); @@ -314,6 +353,8 @@ int main(int argc, char** argv) { gap = r.reason.empty() ? error : r.reason; break; } + if (duplicate_before && capture_duplicate(*duplicate_before, g, duplicate_directory)) + duplicate_captured = true; if (r.kind == TurnDeskKind::CareerComplete) { ++played; std::printf("turn %d (day %u): career complete\n", played, r.date); diff --git a/tools/ci/build_runnable_tests.py b/tools/ci/build_runnable_tests.py new file mode 100644 index 0000000..d94cf35 --- /dev/null +++ b/tools/ci/build_runnable_tests.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-3.0-only +"""Build products and every configured test program, without unused data fixtures.""" +import argparse +from pathlib import Path +import re +import subprocess + +TEST = re.compile(r'^add_test\((?:\[=*\[.*?\]=*\]|"[^"]*"|[^ )]+)\s+"((?:\\.|[^"\\])*)"') +HOST = re.compile(r'(?:python(?:[0-9.]+)?|cmake|ctest)(?:\.exe)?$', re.I) + + +def targets_for_tests(build): + build = build.resolve(strict=True) + targets = {'openbmh_play', 'openbmh_cli'} + tests = 0 + for file in sorted(build.rglob('CTestTestfile.cmake')): + for line in file.read_text(encoding='utf-8').splitlines(): + if not line.startswith('add_test('): + continue + match = TEST.match(line) + if not match: + raise RuntimeError('Unrecognized generated test command; refusing to omit a test') + tests += 1 + command = match.group(1).replace('\\"', '"').replace('\\\\', '\\') + executable = Path(command).resolve() + if executable.is_relative_to(build): + name = executable.name + if name.lower().endswith('.exe'): + name = name[:-4] + targets.add('openbmh_play' if name == 'OpenBMH' else name) + elif not HOST.fullmatch(executable.name): + raise RuntimeError('Unrecognized external test executable; refusing to omit a test') + if not tests: + raise RuntimeError('No configured tests found') + return sorted(targets), tests + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--build', type=Path, required=True) + parser.add_argument('--config', default='Release') + parser.add_argument('--parallel', type=int, default=2) + parser.add_argument('--list', action='store_true') + args = parser.parse_args() + targets, count = targets_for_tests(args.build) + print(f'{count} configured tests; {len(targets)} product/test build targets', flush=True) + if args.list: + print('\n'.join(targets)) + else: + subprocess.run(['cmake', '--build', str(args.build), '--config', args.config, + '--parallel', str(args.parallel), '--target', *targets], check=True) + + +if __name__ == '__main__': + main() diff --git a/tools/ci/test_build_runnable_tests.py b/tools/ci/test_build_runnable_tests.py new file mode 100644 index 0000000..0413098 --- /dev/null +++ b/tools/ci/test_build_runnable_tests.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-3.0-only +import sys +import tempfile +from pathlib import Path +import unittest +from build_runnable_tests import targets_for_tests + + +class BuildDiscoveryTests(unittest.TestCase): + def setUp(self): + self.temporary = tempfile.TemporaryDirectory(prefix='ci build ') + self.addCleanup(self.temporary.cleanup) + self.build = Path(self.temporary.name) / 'build' + self.build.mkdir() + + def write(self, text): + (self.build / 'CTestTestfile.cmake').write_text(text, encoding='utf-8') + + def test_required_programs_and_optional_data_skip(self): + self.write(f'add_test([=[unit]=] "{self.build.as_posix()}/unit_suite.exe")\n' + f'add_test([=[private]=] "{self.build.as_posix()}/openbmh_test_skip.exe" "missing input")\n' + f'add_test([=[python]=] "{Path(sys.executable).as_posix()}" "check.py")\n') + targets, count = targets_for_tests(self.build) + self.assertEqual(count, 3) + self.assertEqual(targets, ['openbmh_cli', 'openbmh_play', 'openbmh_test_skip', 'unit_suite']) + + def test_nested_test_and_product_output_name(self): + self.write(f'add_test([=[version]=] "{self.build.as_posix()}/OpenBMH.exe" "--version")\n') + nested = self.build / 'src' / 'ui' + nested.mkdir(parents=True) + (nested / 'CTestTestfile.cmake').write_text( + f'add_test([=[ui]=] "{nested.as_posix()}/ui_suite")\n', encoding='utf-8') + targets, count = targets_for_tests(self.build) + self.assertEqual(count, 2) + self.assertEqual(targets, ['openbmh_cli', 'openbmh_play', 'ui_suite']) + + def test_unknown_external_binary_is_not_silently_dropped(self): + outside = self.build.parent / 'unknown-suite' + self.write(f'add_test([=[outside]=] "{outside.as_posix()}")\n') + with self.assertRaisesRegex(RuntimeError, 'external'): + targets_for_tests(self.build) + + def test_unrecognized_command_and_empty_configuration_fail(self): + self.write('add_test(unsupported-syntax)\n') + with self.assertRaises(RuntimeError): + targets_for_tests(self.build) + self.write('# no tests\n') + with self.assertRaises(RuntimeError): + targets_for_tests(self.build) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/package/test_verify_ci_release.py b/tools/package/test_verify_ci_release.py new file mode 100644 index 0000000..c3c9561 --- /dev/null +++ b/tools/package/test_verify_ci_release.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-3.0-only +import json +from pathlib import Path +import tempfile +import unittest +import zipfile +from verify_ci_release import PLATFORMS, verify + + +class ReleaseVerificationTests(unittest.TestCase): + def setUp(self): + self.temporary = tempfile.TemporaryDirectory() + self.addCleanup(self.temporary.cleanup) + self.root = Path(self.temporary.name) + self.dist = self.root / 'dist'; self.dist.mkdir() + self.reports = self.root / 'reports'; self.reports.mkdir() + self.sha = 'a' * 40 + for platform in (*PLATFORMS, 'source'): + with zipfile.ZipFile(self.dist / f'OpenBMH-1.0.0-{platform}.zip', 'w') as z: + if platform == 'source': + z.writestr('source/SOURCE_MANIFEST.json', json.dumps({'version': '1.0.0', 'project_commit': self.sha})) + else: + z.writestr('synthetic.txt', 'synthetic package') + for platform in PLATFORMS: + folder = self.reports / ('tests-' + platform); folder.mkdir() + (folder / 'test-results.xml').write_text('') + + def run_verify(self, sha=None): + return verify(self.dist, self.reports, 'v1.0.0', sha or self.sha, 123, 'example/project') + + def test_matching_release_records_skips_and_checksums(self): + report = self.run_verify() + self.assertEqual(report['tests']['linux-x64']['skipped'], 1) + self.assertEqual(len(report['archive_sha256']), 4) + self.assertEqual(len((self.dist / 'SHA256SUMS').read_text().splitlines()), 5) + + def test_wrong_revision_rejected(self): + with self.assertRaisesRegex(ValueError, 'different'): + self.run_verify('b' * 40) + + def test_missing_platform_archive_rejected(self): + (self.dist / 'OpenBMH-1.0.0-windows-x64.zip').unlink() + with self.assertRaisesRegex(ValueError, 'archive set'): + self.run_verify() + + def test_failed_or_all_skipped_reports_rejected(self): + path = self.reports / 'tests-windows-x64' / 'test-results.xml' + path.write_text('') + with self.assertRaisesRegex(ValueError, 'failed'): + self.run_verify() + path.write_text('') + with self.assertRaisesRegex(ValueError, 'execute'): + self.run_verify() + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/package/verify_ci_release.py b/tools/package/verify_ci_release.py new file mode 100644 index 0000000..ca39e2e --- /dev/null +++ b/tools/package/verify_ci_release.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-3.0-only +"""Bind release archives to one successful CI revision and its test reports.""" +import argparse +import hashlib +import json +from pathlib import Path +import re +import xml.etree.ElementTree as ET +import zipfile + +PLATFORMS = ('windows-x64', 'macos-arm64', 'linux-x64') + + +def verify(dist, reports, tag, source_sha, ci_run, repository): + match = re.fullmatch(r'v([0-9]+\.[0-9]+\.[0-9]+(?:-[A-Za-z0-9][A-Za-z0-9.-]*)?)', tag) + if not match or not re.fullmatch(r'[0-9a-f]{40}', source_sha) or ci_run <= 0: + raise ValueError('Invalid release identity') + version = match.group(1) + expected = {f'OpenBMH-{version}-{p}.zip' for p in (*PLATFORMS, 'source')} + if {p.name for p in dist.glob('*.zip')} != expected: + raise ValueError('Release archive set does not match the tag/platforms') + with zipfile.ZipFile(dist / f'OpenBMH-{version}-source.zip') as source: + manifests = [n for n in source.namelist() if n.endswith('/SOURCE_MANIFEST.json')] + if len(manifests) != 1: + raise ValueError('Missing or ambiguous corresponding-source manifest') + manifest = json.loads(source.read(manifests[0])) + if manifest['version'] != version or manifest['project_commit'] != source_sha: + raise ValueError('Corresponding source is from a different version or revision') + tests = {} + for platform in PLATFORMS: + root = ET.parse(reports / ('tests-' + platform) / 'test-results.xml').getroot() + suites = list(root.iter('testsuite')) + if not suites or next(root.iter('failure'), None) is not None or next(root.iter('error'), None) is not None: + raise ValueError('Missing or failed platform test results') + values = {key: sum(int(s.get(key, '0')) for s in suites) + for key in ('tests', 'failures', 'errors', 'skipped')} + if values['failures'] or values['errors'] or values['tests'] <= values['skipped']: + raise ValueError('Platform test results did not execute passing tests') + tests[platform] = values + archives = {name: hashlib.sha256((dist / name).read_bytes()).hexdigest() for name in sorted(expected)} + report = {'version': version, 'tag': tag, 'source_commit': source_sha, + 'ci_run': ci_run, 'ci_url': f'https://github.com/{repository}/actions/runs/{ci_run}', + 'tests': tests, 'archive_sha256': archives} + output = dist / 'QA-REPORT.json' + output.write_text(json.dumps(report, indent=2) + '\n', encoding='utf-8') + checksums = dict(archives) + checksums[output.name] = hashlib.sha256(output.read_bytes()).hexdigest() + (dist / 'SHA256SUMS').write_text(''.join(f'{digest} {name}\n' for name, digest in sorted(checksums.items())), encoding='utf-8') + return report + + +def main(): + p = argparse.ArgumentParser(description=__doc__) + p.add_argument('--dist', type=Path, required=True) + p.add_argument('--reports', type=Path, required=True) + p.add_argument('--tag', required=True) + p.add_argument('--source-sha', required=True) + p.add_argument('--ci-run', type=int, required=True) + p.add_argument('--repository', required=True) + a = p.parse_args() + verify(a.dist, a.reports, a.tag, a.source_sha, a.ci_run, a.repository) + print('Release archives, source revision and all platform reports verified') + + +if __name__ == '__main__': + main()