Launcher: use HORIZON_GITHUB_TOKEN for GitHub's API when given; CI passes its own
Shared CI runners hit GitHub's anonymous rate limit in the smoke test (launcher 0.1.2's macOS build failed twice on it). Players never set the variable, so nothing changes for them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -59,6 +59,7 @@ jobs:
|
||||
- name: Smoke test
|
||||
env:
|
||||
HORIZON_LAUNCHER_NO_SELF_UPDATE: '1'
|
||||
HORIZON_GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export HORIZON_LAUNCHER_HOME="${RUNNER_TEMP//\\//}/horizon-launcher-smoke"
|
||||
|
||||
@@ -59,7 +59,14 @@ fn agent() -> ureq::Agent {
|
||||
}
|
||||
|
||||
fn get(url: &str) -> Result<ureq::Response, String> {
|
||||
agent().get(url).call().map_err(|e| match e {
|
||||
let mut request = agent().get(url);
|
||||
// CI runners share addresses and hit GitHub's anonymous rate limit; they pass their own token.
|
||||
if let Some(token) = std::env::var("HORIZON_GITHUB_TOKEN").ok().filter(|t| !t.is_empty()) {
|
||||
if url.starts_with("https://api.github.com/") {
|
||||
request = request.set("Authorization", &format!("Bearer {token}"));
|
||||
}
|
||||
}
|
||||
request.call().map_err(|e| match e {
|
||||
ureq::Error::Status(403, _) => "GitHub's rate limit was reached. Try again in a few minutes.".into(),
|
||||
ureq::Error::Status(code, _) => format!("{url} answered {code}"),
|
||||
ureq::Error::Transport(t) => format!("No connection: {t}"),
|
||||
|
||||
Reference in New Issue
Block a user