Various CI fixes (#3813)

## Issue Addressed

Closes #3812
Closes #3750
Closes #3705
This commit is contained in:
Michael Sproul
2022-12-20 01:34:52 +00:00
parent 53aad18da3
commit 59a7a4703c
5 changed files with 51 additions and 37 deletions

View File

@@ -1,7 +1,10 @@
//! This build script downloads the latest Web3Signer release and places it in the `OUT_DIR` so it
//! can be used for integration testing.
use reqwest::Client;
use reqwest::{
header::{self, HeaderValue},
Client,
};
use serde_json::Value;
use std::env;
use std::fs;
@@ -15,10 +18,15 @@ const FIXED_VERSION_STRING: Option<&str> = None;
#[tokio::main]
async fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
download_binary(out_dir.into()).await;
// Read a Github API token from the environment. This is intended to prevent rate-limits on CI.
// We use a name that is unlikely to accidentally collide with anything the user has configured.
let github_token = env::var("LIGHTHOUSE_GITHUB_TOKEN");
download_binary(out_dir.into(), github_token.as_deref().unwrap_or("")).await;
}
pub async fn download_binary(dest_dir: PathBuf) {
pub async fn download_binary(dest_dir: PathBuf, github_token: &str) {
let version_file = dest_dir.join("version");
let client = Client::builder()
@@ -33,8 +41,11 @@ pub async fn download_binary(dest_dir: PathBuf) {
env_version
} else {
// Get the latest release of the web3 signer repo.
let mut token_header_value = HeaderValue::from_str(github_token).unwrap();
token_header_value.set_sensitive(true);
let latest_response: Value = client
.get("https://api.github.com/repos/ConsenSys/web3signer/releases/latest")
.header(header::AUTHORIZATION, token_header_value)
.send()
.await
.unwrap()