mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
ci: add test/clippy workflow and gate live/token tests
The docker workflow only builds/pushes; tests were a local responsibility. Add .github/workflows/ci.yml with two layers: - test: cargo fmt --check + cargo clippy --workspace --all-targets -D warnings + cargo test --workspace (fully offline, no secrets) on every push/PR, including forks. - live: the #[ignore]d live-network tests plus the pixiv token-gated tests, run on schedule / manual dispatch / tag pushes only (fork PRs cannot read repository secrets), with PIXIV_REFRESH_TOKEN / TWITTER_AUTH_TOKEN injected and continue-on-error for flaky sites. Test gating (documented in AGENTS.md): - live-network tests now carry #[ignore = "live network: ..."] (twitter 3, bsky 2, pixiv bogus-token 1) and run via -- --ignored live. - pixiv token tests early-return when PIXIV_REFRESH_TOKEN is absent or empty (an unset GitHub secret arrives as ""); test_fetch previously failed without a token. Also fixes the three clippy assertions_on_constants warnings in send.rs (required for -D warnings).
This commit is contained in:
@@ -422,7 +422,13 @@ mod tests {
|
||||
async fn download_media_pixiv_original_with_referer() {
|
||||
// Proves the Referer header is attached for i.pximg.net: a header-less
|
||||
// GET to a pixiv original URL is rejected with 403.
|
||||
if std::env::var("PIXIV_REFRESH_TOKEN").is_err() {
|
||||
// Empty-string check too: an unset CI secret arrives as "" (GitHub
|
||||
// Actions), which would otherwise run the test tokenless and fail.
|
||||
if std::env::var("PIXIV_REFRESH_TOKEN")
|
||||
.ok()
|
||||
.filter(|s| !s.is_empty())
|
||||
.is_none()
|
||||
{
|
||||
eprintln!("skipping: no PIXIV_REFRESH_TOKEN");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user