Skip to content

Commit a9d855b

Browse files
authored
Run archiver tests weekly instead of on CI (#288)
* ignore archiver test by default also extract a constant * add archiver ci * dont clone styles on ci * run archiver tests on releases (draft or not) * bump toolchain to rust 1.83.0
1 parent edec836 commit a9d855b

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

.github/workflows/archive.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Weekly archive up-to-date check
2+
on:
3+
schedule:
4+
- cron: 00 3 * * 1
5+
workflow_dispatch:
6+
release:
7+
# Run on draft and final releases
8+
types: [published]
9+
10+
env:
11+
RUSTFLAGS: "-Dwarnings"
12+
RUSTDOCFLAGS: "-Dwarnings"
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: dtolnay/rust-toolchain@stable
20+
- name: Check out CSL styles
21+
run: |
22+
cd ..
23+
git clone --depth 1 https://github.com/citation-style-language/styles
24+
- name: Check if archives are up-to-date
25+
run: cargo test --test archiver -- --ignored

.github/workflows/ci.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v4
1313
- uses: dtolnay/rust-toolchain@stable
14-
- name: Check out CSL styles
15-
run: |
16-
cd ..
17-
git clone --depth 1 https://github.com/citation-style-language/styles
1814
- run: cargo build
1915
- run: cargo test --features csl-json
2016

@@ -23,7 +19,7 @@ jobs:
2319
runs-on: ubuntu-latest
2420
steps:
2521
- uses: actions/checkout@v4
26-
- uses: dtolnay/rust-toolchain@1.80.0
22+
- uses: dtolnay/rust-toolchain@1.83.0
2723
with:
2824
components: clippy, rustfmt
2925
- uses: Swatinem/rust-cache@v2

tests/archiver.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,19 @@ const ARCHIVE_STYLES_PATH: &str = "archive/styles/";
3434
const ARCHIVE_LOCALES_PATH: &str = "archive/locales/";
3535
const ARCHIVE_SRC_PATH: &str = "src/csl/archive.rs";
3636

37-
/// Always archive.
37+
const UPDATE_ARCHIVES_ENV_VAR: &str = "HAYAGRIVA_ARCHIVER_UPDATE";
38+
39+
/// Always archive CSL styles from upstream.
40+
///
41+
/// Ignore by default so CI and tests can pass despite outdated archives.
42+
/// This specific test should rather be run periodically using the command
43+
/// below:
44+
///
45+
/// ```sh
46+
/// cargo test --test archiver -- --ignored
47+
/// ```
3848
#[test]
49+
#[ignore]
3950
fn always_archive() {
4051
ensure_repos().unwrap_or_else(|err| panic!("Downloading repos failed: {}", err));
4152
create_archive().unwrap_or_else(|err| panic!("{}", err));
@@ -106,7 +117,7 @@ fn create_archive() -> Result<(), ArchivalError> {
106117
// Without "HAYAGRIVA_ARCHIVER_UPDATE=1", we only check if the archive
107118
// files are up-to-date.
108119
let should_write =
109-
std::env::var_os("HAYAGRIVA_ARCHIVER_UPDATE").is_some_and(|var| var == "1");
120+
std::env::var_os(UPDATE_ARCHIVES_ENV_VAR).is_some_and(|var| var == "1");
110121

111122
let mut w = String::new();
112123
let mut styles: Vec<_> = iter_files(&style_path, "csl")
@@ -453,8 +464,7 @@ impl fmt::Display for ArchivalError {
453464
Self::NeedsUpdate(item) => {
454465
write!(
455466
f,
456-
"{} is outdated, run archiver tests with env var 'HAYAGRIVA_ARCHIVER_UPDATE=1' to update",
457-
item
467+
"{item} is outdated, run archiver tests with env var '{UPDATE_ARCHIVES_ENV_VAR}=1' to update",
458468
)
459469
}
460470
}

0 commit comments

Comments
 (0)