Repository navigation
Format times without humantime, and cache apt archives in dylint - #25
vinniefalco wants to merge 2 commits into
Conversation
The advisory `RUSTSEC-2026-0542` marks `humantime` as unmaintained, and the workspace used one function of it, `format_rfc3339_seconds`, to stamp a time. The new module `rfc3339.rs` writes that text with the standard library alone, and `now_rfc3339` moves there from `actor.rs`. The dependency is removed, and so is the `deny.toml` entry that accepted the advisory. - `rfc3339_of_seconds` takes whole seconds since the Unix epoch as a `u64` and returns `YYYY-MM-DDTHH:MM:SSZ`. `now_rfc3339` reads the clock and calls it through `rfc3339_of`, so the tests pin exact texts with no clock. - The date comes from the `civil_from_days` algorithm of Howard Hinnant, and a comment cites its address. The arithmetic is unsigned, because no day is before 1970. - A clock before the Unix epoch reads as the epoch, `1970-01-01T00:00:00Z`. The old code panicked there. - A time after `9999-12-31T23:59:59Z` prints its year with every digit it has, as in `10000-01-01T00:00:00Z`, which is no RFC 3339 text. The old code panicked there too. The count `u64::MAX` formats. - The time is stored as text, and `actor.rs` reads the time of a grant back as text. It parses none. - The `ignore` list of `deny.toml` is `ignore = []` again, and cargo-deny passes without the entry. - `Cargo.lock` loses the `humantime` package and its line in the dependencies of the workspace crate. No other line of it changes. - The tests pin eight fixed times from 1970 through 9999, among them both ends of a leap day and the two sides of the end of February 2100, and each of the two rules. No test compares the text with `humantime`, and no test sets the system clock outside those years.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change replacing the unmaintained timestamp dependency with a standard-library formatter.
No open issues 🎉
What changed in this PR
Replaces humantime with a standard-library formatter for Workshop’s workspace timestamps, removing the unmaintained dependency and the advisory exception introduced in PR #24.
Changes:
- Adds UTC whole-second formatting with explicit behavior before the Unix epoch and after year 9999.
- Adds fixed-value tests for leap dates, fractional-second truncation, and out-of-range timestamps.
- Redirects timestamp callers and removes
humantimefrom manifests, the lockfile, and advisory exceptions.
| File | Description |
|---|---|
deny.toml |
Removes the temporary humantime advisory exception. |
crates/workshop/workspace/src/workspace.rs |
Imports the new timestamp helper. |
crates/workshop/workspace/src/workspace_file/actor.rs |
Uses the new helper and removes the old implementation. |
crates/workshop/workspace/src/workspace_file.rs |
Removes the old helper re-export. |
crates/workshop/workspace/src/rfc3339.rs |
Implements timestamp formatting using the standard library. |
crates/workshop/workspace/src/rfc3339-tests.rs |
Tests date conversion, precision, and boundary behavior. |
crates/workshop/workspace/src/lib.rs |
Registers the formatter module. |
crates/workshop/workspace/Cargo.toml |
Removes the crate’s humantime dependency. |
Cargo.toml |
Removes the shared humantime dependency declaration. |
Cargo.lock |
Removes humantime and its dependency reference. |
Review effort: Balanced
On the `ubuntu-24.04` image apt can download the archives of the Tauri packages at about 60 kB/s, which is 20 minutes for 70 MB and was the limit of the step (actions/runner-images#14823). Four steps of the `dylint` job now keep those archives in an Actions cache: one lists what apt would download and makes the cache key, `actions/cache/restore@v6` restores, the install step hands the restored files to apt and fills the cache directory again, and `actions/cache/save@v6` saves. A run whose cache holds every archive downloads nothing. - apt takes an archive that is already in its directory when the size is right, and it checks no hash of it. So the install step copies a restored file there only when its SHA-256 or SHA-512 is the one apt listed, and apt downloads every other archive itself. - apt lists the MD5 sum of an archive by default, so the list step asks for the SHA-256 with `-o Acquire::ForceHash=sha256`. An archive that is listed with no SHA-256 or SHA-512 is never cached. - The cache key is a hash of the names, sizes, and hashes of the listed archives, sorted, without their addresses, because the mirror differs from runner to runner. `restore-keys` lets a run with a new list start from the cache of an older one. - A run with no cache does what the job did before: apt downloads every archive and installs it. A listing that fails, a restore that fails, and a restored file with a wrong hash each cost time and do not fail the job. - The save step is a step of its own before the lint, so a run whose lint fails still saves. It runs only when the restore was no exact hit and `cache-complete` is true, because a cache is never replaced and an incomplete one would stay incomplete. - The install step fails after 30 minutes, where it failed after 20, because a slow download of every archive takes about 20 and a run with no cache must finish once. The list step, which now holds `apt-get update`, fails after 10 minutes, and so does each cache step. - The other jobs that install these packages, one in this workflow and the Linux builds of the Bundle workflow, do not change. The workflow gains no job. - The diff adds no test. Only a CI run executes these steps.
humantimehumantime, and cache apt archives in dylint
There was a problem hiding this comment.
🔵 Needs a closer look
The apt-cache workflow has only mocked and WSL validation; real ubuntu-24.04 GitHub runner cold-cache and exact-hit runs are needed to verify archive handling, cache save/restore, and reuse without downloads.
No open issues 🎉
Review effort: Balanced
This pull request has two commits that are independent of each other. They share a pull request because both come from the
masterbranch of the fork.humantime. A small formatter from the standard library takes the place of the crate, and the stopgap entry indeny.tomlgoes.dylintjob. The apt step of that job takes about 20 minutes since 2026-11-18 and fails about half of the runs, on this pull request's first commit too. The second commit keeps the downloaded archives in an Actions cache.Each part below describes one commit.
1. Format the workspace's times without
humantimeThe workspace used one function of
humantimeto stamp a time. This pull request writes that text with the standard library alone and removes the crate.Why
humantimeas unmaintained. It reports no vulnerability, and it says that no safe upgrade is available.deny.tomldenies an unmaintained crate that the workspace depends on directly, socargo deny checkfailed. Pin the Harness at4afed45fand contract 0.5 #24 accepted the advisory indeny.tomlas a stopgap.The formatter
crates/workshop/workspace/src/rfc3339.rshasrfc3339_of_seconds, which takes whole seconds since the Unix epoch and returnsYYYY-MM-DDTHH:MM:SSZ.now_rfc3339reads the clock and calls it.now_rfc3339was inworkspace_file/actor.rs, and its two callers change only their import.civil_from_daysalgorithm, which a comment cites: https://howardhinnant.github.io/date_algorithms.html#civil_from_days1970-01-01T00:00:00Zthrough9999-12-31T23:59:59Zthe text is whathumantime::format_rfc3339_secondsgave.humantimepanicked in both cases, and the new code panics on no input.1970-01-01T00:00:00Z.10000-01-01T00:00:00Z. That is not an RFC 3339 text.created_atvalue of a workspace file, which this repository writes and never reads, and theadded_atof each grant, which is stored and read back as text.How it was proved equal to
humantimeBefore the crate was removed, a throwaway test compared the new function with
humantime::format_rfc3339_secondsfor 9,557,899 values, and all were equal. The test is not in this pull request.The tests that stay pin fixed values with no dependency: eight times, among them both ends of the leap day of 2000 and the two sides of the end of February 2100, and the two rules. Each expected text was checked against
humantimein the run above.What left the manifests
Cargo.toml: the linehumantime = "2".crates/workshop/workspace/Cargo.toml: the linehumantime.workspace = true.Cargo.lock: thehumantime2.4.0 package and its line in the dependencies ofworkshop-workspace. No other crate needed it, and no other line of the lock changed.deny.toml: the entry for RUSTSEC-2026-0542 and its comment. The list isignore = []again, as it was before pull request 24.What was run here
All of this ran on Windows, on the final tree, with the pinned toolchain 1.99.1.
cargo fmt --all --check: pass.clippyjob's command and thecheck-workshopjob's clippy command, withCARGO_BUILD_WARNINGS=deny: pass.testjob'scargo nextest run: 709 passed, 1 skipped.check-workshopjob's test command, with its stub Gateway staged before and removed after: 514 passed, 4 skipped.docsjob'scargo docand thecheck-workshopjob'scargo doc, withRUSTDOCFLAGS=-D warnings: pass.cargo deny checkandcargo deny --log-level error check, withignore = []: pass. Advisories, bans, licenses, and sources are all ok.cargo audit: exit code 0, with 13 allowed warnings where there were 14.humantimeis not among them.ringis not in the Workshop binary's closure on Windows.cargo dylint --all -- --locked --workspace --all-targets --all-features: pass.cargo test -p build-xtask: 86 passed.node --test crates/workshop/ui/test/docs-claims.mjs: 2 passed.What was not run
uijob. This pull request changes no file of the UI.check-workshop-linux, and the Linux runs of every other job. No job runs on macOS.What no test covers
now_rfc3339calls.2. Cache the Tauri system packages in the
dylintjobThe problem
The
dylintjob installs the Tauri system packages with apt onubuntu-24.04. Since 2026-11-18 that one step takes about 20 minutes, and its limit was 20 minutes, so the job fails about half the time.956e7800tomaster.Need to get 69.7 MB of archives.and thenFetched 69.7 MB in 19min 9s (60.7 kB/s). Every archive came fromus-east-2.ec2.archive.ubuntu.com, with no error and no retry. The package lists arrived fast in the same run:Fetched 12.9 MB in 2s.ci-greenfails whendylintfails, so this blocks pull requests.The cause
The cause is the runner image, not this repository. actions/runner-images issue 14823 reports the same thing for the same packages:
Fetched 74.8 MB in 20min 17s (61.5 kB/s). The image tells apt to leave a mirror only when no data arrives for 15 seconds. A mirror that sends data slowly never trips that, so apt stays on it. The issue is open and has no fix from GitHub.The job cannot move to
ubuntu-22.04, because the prebuiltcargo-dylintanddylint-linkneed glibc 2.38 or later. In the same minute as a slowdylintrun,check-workshop-linuxonubuntu-22.04fetched 52.4 MB in 2 seconds from another mirror.What this changes
Only the
dylintjob ofci.ymlchanges. Its one install step becomes four steps, and the job keeps the downloaded archives (the.debfiles) in an Actions cache, so that apt downloads only the archives the cache lacks.apt-get update, and then asks apt which archives it would download, withapt-get install --print-uris. It writes one line for each archive: the file name, the size, and the SHA-256. The cache key isdylint-apt-archives-and a hash of that sorted list. The key leaves the addresses out, because the mirror differs from runner to runner.actions/cache/restore@v6with that key, and withrestore-keys: dylint-apt-archives-, so that a run whose list is new starts from the newest older cache.apt-get install --download-onlydownloads the rest. Then the step fills the cache directory again with exactly the listed archives, and installs.actions/cache/save@v6. It is a step of its own before the lint, so that a run whose lint fails still saves. It runs only when the restore was not an exact hit and the cache directory holds every listed archive.The package names now sit in one variable of the job,
TAURI_APT_PACKAGES, because two steps hand them to apt.The hash check
apt checks the hash of an archive that it downloads. It does not check an archive that is already in its archive directory: when that file has the expected size, apt uses it as it is. This is in
pkgAcqArchiveinapt-pkg/acquire-item.ccof apt 2.7.14. So a restored file must not reach that directory unchecked.--print-urisapt prints the MD5 sum unless it is told otherwise, so the step passes-o Acquire::ForceHash=sha256.A run with no cache
It does what the job did before. The restore finds nothing, apt downloads every archive and checks it, and the packages are installed. From a slow mirror that still takes about 20 minutes, one time. The run then saves the cache, and the runs after it do not download.
A problem with the cache costs time and does not fail the job:
continue-on-error: true. A restore that fails, or that runs past its limit, is a run with no cache. A save that fails changes nothing else.The job can still fail where it could fail before: when
apt-get update, the download, or the install fails or runs past its limit.The time limits
apt-get update, which took 2 seconds in the slow runs. The same 12.9 MB at 60 kB/s would take under 4 minutes.continue-on-error: true, so the job goes on.Who can read and write the cache
This is from the dependency caching reference of GitHub.
mastersaves into the scope ofmaster. Every branch and every pull request can restore that cache, and that includes pull requests from forks.refs/pull/N/merge) only.masterand other pull requests cannot restore that cache.master, and it cannot write a cache thatmasteror another pull request reads. And a file from any cache is used only when it has the hash from apt's index.One cache is about 70 MB. A new key appears when Ubuntu publishes a new version of a listed package. GitHub removes a cache that no run has used for 7 days.
What does not change
check-workshop-linuxand the Linux builds of the Bundle workflow install the same packages. They are as they were.dylintare as they were and in the same order. The workflow has no new job, so the list of jobs inci-greenis as it was.actions/cache/restoreandactions/cache/save, which are GitHub's own, at the current major versionv6. They use the same Actions cache thatSwatinem/rust-cachealready uses in this job.What was checked on a Windows machine
These checks ran locally, before the change first ran on a GitHub runner:
dylintjob has its old steps in the old order, with the four new steps in the place of the old install step. No other job differs frommaster.bash -naccepts everyrun:script of the job, in the bash 5.3.15 of Git for Windows and in bash 5.3.9 on Ubuntu under WSL.bash --noprofile --norc -eo pipefail), with stand-ins forsudo,apt-get, andapt-config. The stand-in forapt-getaccepts a file in its directory by size alone, as apt does. 20 cases with 75 checks passed in Git Bash, and 19 cases with 73 checks passed in WSL. The cases:%3aand with+apt-configthat failsapt-get install --print-urisof Ubuntu 26.04 under WSL (apt 3.2.0), a command that changes nothing on the system: 188 archives, each with a SHA-256, 23 names with%3a, and no line that the script could not read.node --test crates/workshop/ui/test/docs-claims.mjspasses.The Rust checks were not run, because the change touches no Rust.
What the two runs on this pull request showed
The second commit ran twice on GitHub's runners, in CI run 44444496865: one time with no cache, and one more time as a re-run of the
dylintjob alone.The first run, with no cache. Image
ubuntu-24.04version20261111.127.1, mirrorus-east-2.ec2.archive.ubuntu.com.apt would download 163 archives, and 163 of them have a hash this job checks.Cache not found for input keys: dylint-apt-archives-a4fc0f72492983bc8b1db0492c362e04c748950edbb088da0d64b7134e76a25c, dylint-apt-archives-0 archives come from the cache.Need to get 69.7 MB of archives.Fetched 69.7 MB in 8min 37s (135 kB/s)The cache directory holds 163 of the 163 archives to cache.Cache saved with key: dylint-apt-archives-a4fc0f72492983bc8b1db0492c362e04c748950edbb088da0d64b7134e76a25cThe re-run of the job. Image
ubuntu-24.04version20261111.370.1, mirrorazure.archive.ubuntu.com.apt would download 163 archives, and 163 of them have a hash this job checks.Cache restored from key: dylint-apt-archives-a4fc0f72492983bc8b1db0492c362e04c748950edbb088da0d64b7134e76a25c163 archives come from the cache.Need to get 0 B/69.7 MB of archives.The cache directory holds 163 of the 163 archives to cache.What the two runs show:
actions/cachesaves and restores a directory under the temp directory of the runner.refs/pull/25/merge.Fetchedline for the archives.What they do not show:
master. After the merge, the first run onmasterdownloads everything one more time, becausemastercannot read the cache of a pull request. That run saves the cache that later pull requests start from.The whole
dylintjob took 14 minutes in the first run and 2 minutes 22 seconds in the re-run. Part of that difference is the cargo cache, which the first run also had to fill.Summary by CodeRabbit