diff --git a/.cargo/config.toml b/.cargo/config.toml index ac2b23f8..be89a788 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,3 @@ -[target.x86_64-pc-windows-msvc] -rustflags = ["-C", "target-feature=+crt-static"] +[env] +# We generally want to bypass updates in the build, they should only really be run in CI as they touch many parts of the host +PLOTINATOR_BYPASS_UPDATES = "true" diff --git a/.github/custom_build_setup/build-setup.yml b/.github/custom_build_setup/build-setup.yml new file mode 100644 index 00000000..4d78bf0a --- /dev/null +++ b/.github/custom_build_setup/build-setup.yml @@ -0,0 +1,12 @@ +- name: Install Just + uses: extractions/setup-just@v3 +- name: Install HDF5 + shell: bash + run: just init::install-hdf5-headers + +- name: Run MSI installer (windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + cd just\hdf + msiexec /i HDF5-1.14.0-win64.msi /quiet /qn /norestart diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f6cda4bd..2ae5763f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,6 +17,8 @@ env: RUSTDOCFLAGS: -D warnings RUST_BACKTRACE: 1 RUST_LOG: debug + JUST_VERBOSE: 1 + JUST_COLOR: always jobs: check: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d17ef807..ff526c8c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,7 @@ -# This file was autogenerated by dist: https://opensource.axo.dev/cargo-dist/ +# This file was autogenerated by dist: https://github.com/astral-sh/cargo-dist # # Copyright 2022-2024, axodotdev +# Copyright 2025 Astral Software Inc. # SPDX-License-Identifier: MIT or Apache-2.0 # # CI that: @@ -47,7 +48,7 @@ on: jobs: # Run 'dist plan' (or host) to determine what tasks we need to do plan: - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" outputs: val: ${{ steps.plan.outputs.manifest }} tag: ${{ !github.event.pull_request && github.ref_name || '' }} @@ -58,12 +59,13 @@ jobs: steps: - uses: actions/checkout@v4 with: + persist-credentials: false submodules: recursive - name: Install dist # we specify bash to get pipefail; it guards against the `curl` command # failing. otherwise `sh` won't catch that `curl` returned non-0 shell: bash - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.28.0/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/cargo-dist/releases/download/v0.28.5/cargo-dist-installer.sh | sh" - name: Cache dist uses: actions/upload-artifact@v4 with: @@ -76,7 +78,7 @@ jobs: # but also really annoying to build CI around when it needs secrets to work right.) - id: plan run: | - dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json + dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json --allow-dirty > plan-dist-manifest.json echo "dist ran successfully" cat plan-dist-manifest.json echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT" @@ -117,6 +119,7 @@ jobs: git config --global core.longpaths true - uses: actions/checkout@v4 with: + persist-credentials: false submodules: recursive - name: Install Rust non-interactively if not already installed if: ${{ matrix.container }} @@ -125,12 +128,28 @@ jobs: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y echo "$HOME/.cargo/bin" >> $GITHUB_PATH fi + - name: "Install Just" + uses: "extractions/setup-just@v3" + - name: "Install HDF5" + run: "just init::install-hdf5-headers" + shell: "bash" + - name: "Run MSI installer (windows)" + if: "runner.os == 'Windows'" + run: | + cd just\hdf + msiexec /i HDF5-1.14.0-win64.msi /quiet /qn /norestart + shell: "pwsh" - uses: swatinem/rust-cache@v2 with: key: ${{ join(matrix.targets, '-') }} cache-provider: ${{ matrix.cache_provider }} - name: Install dist run: ${{ matrix.install_dist.run }} + + # Need to overwrite it to fix: https://github.com/astral-sh/cargo-dist/pull/36 + - name: Use patched cargo-dist version (windows) + if: runner.os == 'Windows' + run: cargo install cargo-dist --git https://github.com/CramBL/cargo-dist --branch fix-ignored-msvc-crt-static-flag --rev a4cabb10395c7b275ea40d1636cd2d0e58be8af6 --force # Get the dist-manifest - name: Fetch local artifacts uses: actions/download-artifact@v4 @@ -144,7 +163,7 @@ jobs: - name: Build artifacts run: | # Actually do builds and make zips and whatnot - dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json + dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --allow-dirty --output-format=json ${{ matrix.dist_args }} > dist-manifest.json echo "dist ran successfully" - id: cargo-dist name: Post-build @@ -172,13 +191,14 @@ jobs: needs: - plan - build-local-artifacts - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json steps: - uses: actions/checkout@v4 with: + persist-credentials: false submodules: recursive - name: Install cached dist uses: actions/download-artifact@v4 @@ -196,7 +216,7 @@ jobs: - id: cargo-dist shell: bash run: | - dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json + dist build ${{ needs.plan.outputs.tag-flag }} --allow-dirty --output-format=json "--artifacts=global" > dist-manifest.json echo "dist ran successfully" # Parse out what we just built and upload it to scratch storage @@ -222,12 +242,13 @@ jobs: if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" outputs: val: ${{ steps.host.outputs.manifest }} steps: - uses: actions/checkout@v4 with: + persist-credentials: false submodules: recursive - name: Install cached dist uses: actions/download-artifact@v4 @@ -245,7 +266,7 @@ jobs: - id: host shell: bash run: | - dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json + dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --allow-dirty --output-format=json > dist-manifest.json echo "artifacts uploaded and released successfully" cat dist-manifest.json echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT" @@ -286,10 +307,11 @@ jobs: # still allowing individual publish jobs to skip themselves (for prereleases). # "host" however must run to completion, no skipping allowed! if: ${{ always() && needs.host.result == 'success' }} - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v4 with: + persist-credentials: false submodules: recursive diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ae13054..86e6a0d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +## [1.12.0] + +### Changed + +- Move from the discontinued original `cargo-dist` to the [fork maintained by astral](https://github.com/astral-sh/cargo-dist) +- Use the forked `cargo-dist` with the MSVC CRT linker configuration fix in the release workflow (astral [PR here](https://github.com/astral-sh/cargo-dist/pull/36)) +- Avoid statically linking MSVC CRT to allow statically linking HDF5 on windows. +- Disallow bypassing updates in CI, to force tests to run update scenarios + ### Dependencies - `anyhow`: 1.0.97 → 1.0.98 ([#228](https://github.com/luftkode/plotinator3000/pull/228)) diff --git a/Cargo.lock b/Cargo.lock index 1d9257bf..4e2eb4ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2455,7 +2455,7 @@ checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "log_if" -version = "1.11.1" +version = "1.12.0" dependencies = [ "chrono", "log", @@ -3215,7 +3215,7 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "plot_util" -version = "1.11.1" +version = "1.12.0" dependencies = [ "chrono", "egui", @@ -3232,7 +3232,7 @@ dependencies = [ [[package]] name = "plotinator3000" -version = "1.11.1" +version = "1.12.0" dependencies = [ "axoupdater", "chrono", @@ -3271,11 +3271,11 @@ dependencies = [ [[package]] name = "plotinator_macros" -version = "1.11.1" +version = "1.12.0" [[package]] name = "plotinator_mqtt" -version = "1.11.1" +version = "1.12.0" dependencies = [ "anyhow", "egui_plot", @@ -4124,7 +4124,7 @@ checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" [[package]] name = "skytem_hdf" -version = "1.11.1" +version = "1.12.0" dependencies = [ "byteorder", "chrono", @@ -4147,7 +4147,7 @@ dependencies = [ [[package]] name = "skytem_logs" -version = "1.11.1" +version = "1.12.0" dependencies = [ "byteorder", "chrono", @@ -4397,7 +4397,7 @@ dependencies = [ [[package]] name = "test_util" -version = "1.11.1" +version = "1.12.0" dependencies = [ "paste", "testresult", diff --git a/Cargo.toml b/Cargo.toml index aa70d004..bc6465fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ members = ["crates/*"] [workspace.package] authors = ["SkyTEM Surveys", "Marc Beck König"] -version = "1.11.1" +version = "1.12.0" edition = "2024" rust-version = "1.85.0" license = "MIT OR Apache-2.0" diff --git a/Justfile b/Justfile index 613560d2..c402d066 100644 --- a/Justfile +++ b/Justfile @@ -1,12 +1,13 @@ import 'just/mod.just' # CI only recipes, `just -l ci` to list them mod ci 'just/ci.just' +# init only recipes, `just -l init` to list them +mod init 'just/init.just' set windows-shell := ["powershell.exe", "-c"] PROJECT_NAME := "plotinator3000" -alias i := init alias t := test alias l := lint alias fmt := format @@ -24,12 +25,7 @@ export RUST_LOG := env_var_or_default("RUST_LOG", "info") export PLOTINATOR_BYPASS_UPDATES := env_var_or_default("PLOTINATOR_BYPASS_UPDATES", "true") @_default: - just --list --no-aliases - -[group("Init")] -init: install-devtools - @echo "Run {{BOLD + YELLOW}}install-extra-devtools{{NORMAL}} for some adittional productivity tools that fit into the existent workflow" - @echo "Run {{BOLD + YELLOW}}apt-install-hdf5-header{{NORMAL}} to get HDF5 headers for developing HDF5 features on linux" + just --list [doc("Checks both native and wasm"), group("Check"), no-exit-message] check-all: check check-wasm diff --git a/dist-workspace.toml b/dist-workspace.toml index 5e546cfb..b443989b 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -4,7 +4,7 @@ members = ["cargo:."] # Config for 'dist' [dist] # The preferred dist version to use in CI (Cargo.toml SemVer syntax) -cargo-dist-version = "0.28.0" +cargo-dist-version = "0.28.5" # CI backends to support ci = "github" # The installers to generate for each app @@ -17,3 +17,6 @@ install-path = "CARGO_HOME" install-updater = false # Which actions to run on pull requests pr-run-mode = "upload" +# Whether +crt-static should be used on msvc +msvc-crt-static = false +github-build-setup = "../custom_build_setup/build-setup.yml" diff --git a/just/init.just b/just/init.just index 47c3f6e4..c93d6872 100644 --- a/just/init.just +++ b/just/init.just @@ -1,3 +1,11 @@ +set windows-shell := ["powershell.exe", "-c"] + +[group("Init")] +init: install-devtools + @echo "Run {{BOLD + YELLOW}}install-extra-devtools{{NORMAL}} for some adittional productivity tools that fit into the existent workflow" + @echo "Run {{BOLD + YELLOW}}apt-install-hdf5-headers{{NORMAL}} to get HDF5 headers for developing HDF5 features on linux" + + # Trunk is used to serve the app with a webserver, cargo-dist is used to generate and update workflows for distributing installers for various platforms [group("Init"), doc("Install the required tools for performing all dev tasks for the project")] install-devtools: @@ -14,5 +22,37 @@ install-extra-devtools: cargo install bacon --locked [group("Init")] -apt-install-hdf5-header: - sudo apt install libhdf5-dev \ No newline at end of file +apt-install-hdf5-headers: + sudo apt install libhdf5-dev + +[windows] +msi-install-hdf5-headers: + #!/usr/bin/env bash + set -eo pipefail + VERSION="1.14.0" + DL_URL="https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-${VERSION}/bin/windows/hdf5-${VERSION}-Std-win10_64-vs16.zip" + # Download and extract HDF5 + curl -L -o hdf5.zip "${DL_URL}" + unzip hdf5.zip + if [[ "${GITHUB_ACTIONS}" == "true" ]]; then + just init::set-github-hdf5-env-vars "${VERSION}" + fi + + +[windows] +set-github-hdf5-env-vars VERSION: + echo "HDF5_DIR=C:\\Program Files\\HDF_Group\\HDF5\\{{VERSION}}" >> $GITHUB_ENV + echo "C:\\Program Files\\HDF_Group\\HDF5\\{{VERSION}}\\bin" >> $GITHUB_PATH + +[macos] +brew-install-hdf5-headers: + brew install hdf5 + +[linux] +install-hdf5-headers: apt-install-hdf5-headers + +[macos] +install-hdf5-headers: brew-install-hdf5-headers + +[windows] +install-hdf5-headers: msi-install-hdf5-headers \ No newline at end of file diff --git a/just/mod.just b/just/mod.just index 73e6941e..af88a6ee 100644 --- a/just/mod.just +++ b/just/mod.just @@ -1,3 +1,2 @@ import 'default_cmd.just' -import 'init.just' import 'mqtt.just' diff --git a/src/updater.rs b/src/updater.rs index 9c45e520..68d30251 100644 --- a/src/updater.rs +++ b/src/updater.rs @@ -209,7 +209,15 @@ pub fn update_if_applicable() -> axoupdater::AxoupdateResult { /// Check for the environment variable to bypass updates fn bypass_updates() -> bool { + // This is generally set in the build environment (see config.toml) if let Ok(value) = env::var(BYPASS_UPDATES_ENV_VAR) { + // If we're in the build environment and we detect CI, we don't allow bypassing updates + if let Ok(value) = env::var("GITHUB_ACTIONS") { + if value == "true" { + log::info!("GitHub actions detected, disabling bypass updates"); + return false; + } + } if value == "1" || value.eq_ignore_ascii_case("true") { log::info!("Update bypassed due to environment variable."); return true;