diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index e5da47888a..c944f0515f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -65,6 +65,7 @@ jobs: needs: changed if: needs.changed.outputs.run == 'true' runs-on: ubuntu-latest + timeout-minutes: 60 outputs: tested: ${{ steps.data.outputs.ok }} steps: @@ -73,7 +74,10 @@ jobs: - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 with: save-if: false - - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 + # Restored and saved as separate steps: the combined action would save a set missing a file + # whose download failed, and an exact hit is never saved again. + - id: cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 with: path: workflow-data key: workflow-data-census-2024-1 @@ -87,7 +91,7 @@ jobs: while read -r sum url; do file="${url##*/}" if ! echo "$sum $file" | sha256sum -c --status 2>/dev/null; then - curl -sSfL --retry 3 -o "$file" "$url" || { echo "::warning::could not download $url"; ok=false; continue; } + curl -sSfL --retry 3 --retry-max-time 600 --connect-timeout 30 --max-time 300 -o "$file" "$url" || { echo "::warning::could not download $url"; ok=false; continue; } echo "$sum $file" | sha256sum -c || { echo "::error::$file has changed: update its checksum and check the test"; exit 1; } fi done <<'LIST' @@ -95,6 +99,12 @@ jobs: 38cdd818f50248f67fabf4baf4b82df4ed6110dcaafebcbe4d4f9a389bb47ab8 https://www2.census.gov/geo/docs/maps-data/data/gazetteer/2024_Gazetteer/2024_gaz_tracts_47.txt LIST echo "ok=$ok" >> "$GITHUB_OUTPUT" + - name: Keep the Census files + if: steps.data.outputs.ok == 'true' && steps.cache.outputs.cache-hit != 'true' + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 + with: + path: workflow-data + key: workflow-data-census-2024-1 - name: Run the workflow tests on them if: steps.data.outputs.ok == 'true' env: @@ -104,8 +114,9 @@ jobs: report: name: Report needs: [changed, rust, workflows] - # A cancelled run is neither a failure nor a fix. - if: always() && github.event_name == 'schedule' && needs.changed.outputs.run == 'true' && needs.rust.result != 'cancelled' && needs.workflows.result != 'cancelled' + # A cancelled run is neither a failure nor a fix. A job that ran out of time ends cancelled too, + # but the run isn't: that is a failure. + if: ${{ !cancelled() && github.event_name == 'schedule' && needs.changed.outputs.run == 'true' }} runs-on: ubuntu-latest permissions: issues: write diff --git a/crates/engine/tests/workflows.rs b/crates/engine/tests/workflows.rs index 8e040efb5f..e3337b8be8 100644 --- a/crates/engine/tests/workflows.rs +++ b/crates/engine/tests/workflows.rs @@ -379,8 +379,9 @@ fn parcel_id(col: usize, row: usize) -> String { /// The parcels and zoning layers, and an assessment table to join to the parcels. /// -/// The table keys parcels by the same text ids. It has no row for the last parcel, and has a row -/// for "101": the first parcel's id read as a number, which must not match it. +/// The table keys parcels by the same text ids. It has no rows for "00103", which straddles the +/// zones' boundary, or for the last parcel, and has a row for "101": the first parcel's id read as +/// a number, which must not match it. fn job_data() -> (String, String, String) { let mut parcels = Vec::new(); for row in 0..3 { @@ -396,7 +397,7 @@ fn job_data() -> (String, String, String) { json!({"type": "Feature", "properties": {"zone": "C2"}, "geometry": rect(SPLIT, SOUTH, WEST + 4.0 * STEP, SOUTH + 2.0 * STEP)}), ]; let mut csv = String::from("parcel_id,value_usd\n"); - for k in 0..11 { + for k in (0..12).filter(|&k| !unassessed(k)) { csv += &format!("{},{}\n", parcel_id(k % 4, k / 4), 100_000 + k * 1_000); } csv += "101,999999\n"; @@ -480,10 +481,16 @@ fn check_totals(stats: &Dataset) { } } -/// The value the assessment table gives a parcel: none for the last, which has no row. +/// Whether the assessment table has no row for the parcel numbered `k` from 0: "00103", split +/// into two pieces by the overlay, and the last, which is in no zone. +fn unassessed(k: usize) -> bool { + k == 2 || k == 11 +} + +/// The value the assessment table gives a parcel: none for those with no row. fn assessment(parcel: &str) -> Field { - let k = parcel.parse::().unwrap_or_else(|_| panic!("{parcel}")) - 101; - if k < 11 { Field::Int(100_000 + k * 1_000) } else { Field::Null } + let k = parcel.parse::().unwrap_or_else(|_| panic!("{parcel}")) - 101; + if unassessed(k) { Field::Null } else { Field::Int(100_000 + k as i64 * 1_000) } } /// Checks that every feature carries its parcel's assessed value; the number checked. @@ -509,13 +516,17 @@ fn join_overlay_summarise_map_save_reopen_and_share() { s.run("gp.run", step).unwrap_or_else(|e| panic!("{}: {e}", step["tool"])); } - // The join matched every parcel by its text id; "101" matched none, and the parcel with no - // assessment kept its row with no value. + // The join matched every parcel by its text id; "101" matched none, and the parcels with no + // assessment kept their rows with no value. assert_eq!(check_values(layer(&s, "assessed")), 12); check_totals(table(&s, "zoned_Statistics")); let zoned = layer(&s, "zoned").clone(); - // Every piece keeps its parcel's value through the overlay. + // Every piece keeps its parcel's value through the overlay, "00103"'s two pieces none. assert_eq!(check_values(&zoned), 13); + let (id, value) = (zoned.field_index("parcel_id").unwrap(), zoned.field_index("value_usd").unwrap()); + let split = (0..zoned.features.len()).filter(|&r| zoned.value(r, id).to_string() == "00103").collect::>(); + assert_eq!(split.len(), 2, "the overlay splits 00103"); + assert!(split.iter().all(|&r| zoned.value(r, value) == &Field::Null), "00103 has no assessment"); let png = dir.path("map.png"); s.run("share.exportMap", &json!({"path": png, "width": 320, "height": 200})).unwrap();