diff --git a/.github/workflows/weekly.yml b/.github/workflows/weekly.yml index f6f5cc59a..0e34792a2 100644 --- a/.github/workflows/weekly.yml +++ b/.github/workflows/weekly.yml @@ -24,6 +24,18 @@ jobs: - name: Build Docker image id: build-docker-image run: cargo xtask build-docker-image -v --no-cache --no-output --from-ci --no-fastfail --tag weekly + timeout-minutes: 1440 + wiki: + name: Ensure wiki is valid + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-rust + - run: git clone ${wikirepo} + shell: bash + env: + wikirepo: https://github.com/${{ github.repository }}.wiki.git + - run: cargo test toml_check -- --nocapture cargo-deny: runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index e1d7c95ef..6f8a690b2 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ You have three options to configure `cross`. All of these options use the TOML f You can directly set [configuration values](docs/cross_toml.md) in your `Cargo.toml` file, under the `[package.metadata.cross]` table, i.e. key prefix. An example config snippet would look like this: -``` +```toml,cargo [package.metadata.cross.target.aarch64-unknown-linux-gnu] xargo = false image = "test-image" diff --git a/src/tests/toml.rs b/src/tests/toml.rs index 45017553d..e8cd68f9d 100644 --- a/src/tests/toml.rs +++ b/src/tests/toml.rs @@ -3,8 +3,10 @@ use std::io::Read; use once_cell::sync::Lazy; use regex::{Regex, RegexBuilder}; +use crate::ToUtf8; + static TOML_REGEX: Lazy = Lazy::new(|| { - RegexBuilder::new(r#"```toml\n(.*?)```"#) + RegexBuilder::new(r#"```toml(.*?)\n(.*?)```"#) .multi_line(true) .dot_matches_new_line(true) .build() @@ -35,16 +37,40 @@ fn toml_check() -> Result<(), Box> { let mut contents = String::new(); file.read_to_string(&mut contents).unwrap(); for matches in TOML_REGEX.captures_iter(&contents) { - let fence = matches.get(1).unwrap(); + let cargo = { + let t = matches.get(1).unwrap().as_str(); + if t.is_empty() { + false + } else if t == ",cargo" { + true + } else { + println!("skipping {t}"); + continue; + } + }; + let fence = matches.get(2).unwrap(); + let fence_content = fence + .as_str() + .replace("$TARGET", "x86_64-unknown-linux-gnu") + .replace("${target}", "x86_64-unknown-linux-gnu"); + eprintln!( - "testing snippet at: {:?}:{:?}", - dir_entry.path(), + "testing snippet at: {}:{:?}", + dir_entry.path().to_utf8()?, text_line_no(&contents, fence.range().start), ); - assert!(crate::cross_toml::CrossToml::parse_from_cross( - fence.as_str(), - crate::shell::MessageInfo::default() - )? + assert!(if !cargo { + crate::cross_toml::CrossToml::parse_from_cross( + &fence_content, + crate::shell::MessageInfo::default(), + )? + } else { + crate::cross_toml::CrossToml::parse_from_cargo( + &fence_content, + crate::shell::MessageInfo::default(), + )? + .unwrap_or_default() + } .1 .is_empty()); }