Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous Updates #2508

Merged
merged 3 commits into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .idea/HarTex.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions api-backend/hartex-backend-routes/src/uptime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,9 @@
use axum::Json;
use axum::extract::Query;
use axum::extract::State;
use axum::http::StatusCode;
use axum_extra::extract::WithRejection;
use bb8_postgres::PostgresConnectionManager;
use bb8_postgres::bb8::Pool;
use bb8_postgres::tokio_postgres::GenericClient;
use bb8_postgres::tokio_postgres::NoTls;
use chrono::DateTime;
use futures_util::stream::TryStreamExt;
use hartex_backend_models::Response;
use hartex_backend_models::uptime::UptimeQuery;
use hartex_backend_models::uptime::UptimeQueryRejection;
Expand Down
9 changes: 8 additions & 1 deletion tools/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tools/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ rust-version = "1.86.0"
[dependencies]
clap = { version = "4.5.24", default-features = false, features = ["std", "usage", "help", "derive", "error-context"] }
fd-lock = "4.0.2"
owo-colors = "4.1.0"
serde = { version = "1.0.217", features = ["derive"] }
toml = "0.8.19"

Expand Down
4 changes: 3 additions & 1 deletion tools/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def main():
help_triggered = args.help or len(sys.argv) == 1

if help_triggered:
print("NOTE: Building bootstrap before processing help command.")
bold = "\033[1m"
end = "\033[0m"
print(f"{bold + 'note:' + end} Building bootstrap before processing help command.")

status = 0
success = "successfully"
Expand Down
4 changes: 3 additions & 1 deletion tools/bootstrap/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def build_bootstrap(self):
if "GITHUB_ACTIONS" in env:
print("::group::Building bootstrap")
else:
print("INFO: Building bootstrap")
bold = "\033[1m"
end = "\033[0m"
print(f"{bold + 'info:' + end} Building bootstrap")

args = self.build_bootstrap_cmd(env)
run_cmd(args, env=env)
Expand Down
8 changes: 5 additions & 3 deletions tools/bootstrap/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use std::process;
use bootstrap::build::Build;
use bootstrap::config::Config;
use bootstrap::config::flags::BootstrapSubcommand;
use owo_colors::OwoColorize;
use fd_lock::RwLock;

/// Entry point to the bootstrap binary, invoked by x.py.
Expand Down Expand Up @@ -64,7 +65,7 @@ pub fn main() {
}
error => {
drop(error);
println!("WARN: build directory locked by process {process_id}");
println!("{} build directory locked by process {process_id}", "warning:".yellow().bold());

let mut lock = lock.write().expect("failed to get write lock on lockfile");
lock.write(process::id().to_string().as_ref())
Expand All @@ -75,9 +76,10 @@ pub fn main() {
}

if config.config_path.is_none() && !matches!(config.subcommand, BootstrapSubcommand::Setup) {
println!("WARN: no `hartex.conf` configuration file is found, using default configuration");
println!("{} no `hartex.conf` configuration file is found, using default configuration", "warning:".yellow().bold());
println!(
"HELP: consider running `./x.py setup` or copying `hartex.example.conf` by running `cp hartex.example.conf hartex.conf`"
"{} consider running `./x.py setup` or copying `hartex.example.conf` by running `cp hartex.example.conf hartex.conf`",
"help:".bold(),
)
}

Expand Down
4 changes: 2 additions & 2 deletions tools/bootstrap/src/steps/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use std::process::Command;
use std::process::exit;

use owo_colors::OwoColorize;
use crate::builder::Builder;
use crate::builder::RunConfig;
use crate::builder::Step;
Expand Down Expand Up @@ -169,7 +169,7 @@ pub fn build_cargo_project(project: &'static str, builder: &Builder<'_>) {
);
command.env("RUSTFLAGS", rustflags);

println!("INFO: Building {project} project");
println!("{} Building {project} project", "info:".bold());
let status = command.status().expect("failed to get status");
if !status.success() {
exit(status.code().unwrap_or(1));
Expand Down
4 changes: 2 additions & 2 deletions tools/bootstrap/src/steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use std::process::Command;
use std::process::exit;

use owo_colors::OwoColorize;
use crate::builder::Builder;
use crate::builder::RunConfig;
use crate::builder::Step;
Expand Down Expand Up @@ -162,7 +162,7 @@ fn check_cargo_project(project: &'static str, builder: &Builder<'_>) {

command.current_dir(pwd);

println!("INFO: Checking {project} project");
println!("{} Checking {project} project", "info:".bold());
let status = command.status().expect("failed to get status");
if !status.success() {
exit(status.code().unwrap_or(1));
Expand Down
6 changes: 3 additions & 3 deletions tools/bootstrap/src/steps/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

use std::fs;

use owo_colors::OwoColorize;
use crate::builder::Builder;
use crate::builder::RunConfig;
use crate::builder::Step;
Expand Down Expand Up @@ -156,9 +156,9 @@ fn clean(project: &'static str, builder: &Builder<'_>) {
.join(env!("BOOTSTRAP_TARGET"))
.join(project);

println!("INFO: deleting {}", dir.display());
println!("{} deleting {}", "info:".bold(), dir.display());
if !dir.exists() {
println!("WARN: directory {} does not exist, skipping", dir.display());
println!("{} directory {} does not exist, skipping", "warning:".yellow().bold(), dir.display());
return;
}

Expand Down
4 changes: 2 additions & 2 deletions tools/bootstrap/src/steps/clippy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use std::process::Command;
use std::process::exit;

use owo_colors::OwoColorize;
use crate::builder::Builder;
use crate::builder::RunConfig;
use crate::builder::Step;
Expand Down Expand Up @@ -152,7 +152,7 @@ fn clippy_cargo_project(project: &'static str, builder: &Builder<'_>) {
command.arg("clippy");
command.current_dir(pwd);

println!("INFO: Clippying {project} project");
println!("{} Clippying {project} project", "info:".bold());
let status = command.status().expect("failed to get status");
if !status.success() {
exit(status.code().unwrap_or(1));
Expand Down
36 changes: 20 additions & 16 deletions tools/bootstrap/src/steps/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use std::io::Write;
use std::path::PathBuf;
use std::str::FromStr;

use owo_colors::OwoColorize;
use crate::builder::Builder;
use crate::builder::RunConfig;
use crate::builder::Step;
Expand Down Expand Up @@ -67,7 +67,7 @@
Self::ApiBackend => "Contribute to the API backend",
Self::DiscordFrontend => "Contribute to the Discord frontend",
Self::Hosting => "Host an instance of HarTex",
Self::Localization => "Contribute to the localization infastructure",

Check failure on line 70 in tools/bootstrap/src/steps/setup.rs

View workflow job for this annotation

GitHub Actions / CodeSpell

infastructure ==> infrastructure
Self::WebFrontend => "Contribute to the web frontend",
Self::None => "Do not modify `hartex.conf`",
}
Expand Down Expand Up @@ -141,7 +141,8 @@
.unwrap_or(PathBuf::from("hartex.conf"));
if path.exists() {
eprintln!(
"WARN: a configuration file already exists at {}",
"{} a configuration file already exists at {}",
"warning:".yellow().bold(),
path.canonicalize()
.expect("failed to canonicalize path")
.display()
Expand Down Expand Up @@ -202,8 +203,8 @@
break match parse_profile(&choice) {
Ok(profile) => profile,
Err(err) => {
eprintln!("ERROR: {err}. Please retry.");
eprintln!("NOTE: press Ctrl+C to exit");
eprintln!("{} {err}. Please retry.", "error:".red().bold());
eprintln!("{} press Ctrl+C to exit", "note:".bold());
continue;
}
};
Expand All @@ -216,8 +217,8 @@
#[allow(clippy::missing_panics_doc)]
#[allow(clippy::module_name_repetitions)]
pub fn setup_profile(config: &Config, profile: SetupProfile) {
println!("INFO: using profile {profile}");
println!("INFO: copying `tools/bootstrap/profiles/hartex.{profile}.conf` to `hartex.conf`");
println!("{} using profile {profile}", "info:".bold());
println!("{} copying `tools/bootstrap/profiles/hartex.{profile}.conf` to `hartex.conf`", "info:".bold());

fs::copy(
config
Expand All @@ -228,7 +229,7 @@
.expect("failed to copy files");

println!(
"INFO: Done. `x.py` will now use the specified configuration in `hartex.conf` for further invocations."
"{} Done. `x.py` will now use the specified configuration in `hartex.conf` for further invocations.", "info:".bold()
);
}

Expand All @@ -247,7 +248,8 @@
let vscode_config = run.builder.config.root.join(".vscode/settings.json");
if vscode_config.exists() {
eprintln!(
"WARN: a vscode configuration file already exists at {}",
"{} a vscode configuration file already exists at {}",
"warning:".yellow().bold(),
vscode_config
.canonicalize()
.expect("failed to canonicalize path")
Expand All @@ -263,7 +265,7 @@
}
}

println!("INFO: Preview of the recommended vscode configuration file is as follows");
println!("{} Preview of the recommended vscode configuration file is as follows", "info:".bold());
println!("{VSCODE_SETTINGS}");

match question_bool("Do you wish to continue?", true) {
Expand All @@ -280,7 +282,7 @@
#[allow(clippy::module_name_repetitions)]
#[allow(clippy::unused_io_amount)]
pub fn setup_vscode_config(builder: &Builder<'_>) {
println!("INFO: writing new `.vscode/settings.json`");
println!("{} writing new `.vscode/settings.json`", "info:".bold());

let vscode_dir = builder.config.root.join(".vscode");
if !vscode_dir.exists() {
Expand Down Expand Up @@ -312,7 +314,8 @@

if fleet_config.exists() {
eprintln!(
"WARN: a fleet configuration file already exists at {}",
"{} a fleet configuration file already exists at {}",
"warning:".yellow().bold(),
fleet_config
.canonicalize()
.expect("failed to canonicalize path")
Expand All @@ -328,7 +331,7 @@
}
}

println!("INFO: Preview of the recommended fleet configuration file is as follows");
println!("{} Preview of the recommended fleet configuration file is as follows", "info:".bold());
println!("{FLEET_SETTINGS}");

match question_bool("Do you wish to continue?", true) {
Expand All @@ -345,7 +348,7 @@
#[allow(clippy::module_name_repetitions)]
#[allow(clippy::unused_io_amount)]
pub fn setup_fleet_config(builder: &Builder<'_>) {
println!("INFO: writing new `.fleet/settings.json`");
println!("{} writing new `.fleet/settings.json`", "info:".bold());

let fleet_dir = builder.config.root.join(".fleet");
if !fleet_dir.exists() {
Expand Down Expand Up @@ -377,7 +380,8 @@

if zed_config.exists() {
eprintln!(
"WARN: a zed configuration file already exists at {}",
"{} a zed configuration file already exists at {}",
"warning:".yellow().bold(),
zed_config
.canonicalize()
.expect("failed to canonicalize path")
Expand All @@ -393,7 +397,7 @@
}
}

println!("INFO: Preview of the recommended Zed configuration file is as follows");
println!("{} Preview of the recommended Zed configuration file is as follows", "info:".bold());
println!("{ZED_SETTINGS}");

match question_bool("Do you wish to continue?", true) {
Expand All @@ -410,7 +414,7 @@
#[allow(clippy::module_name_repetitions)]
#[allow(clippy::unused_io_amount)]
pub fn setup_zed_config(builder: &Builder<'_>) {
println!("INFO: writing new `.zed/settings.json`");
println!("{} writing new `.zed/settings.json`", "info:".bold());

let zed_dir = builder.config.root.join(".zed");
if !zed_dir.exists() {
Expand Down
6 changes: 3 additions & 3 deletions tools/bootstrap/src/steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use std::process::Command;
use std::process::exit;

use owo_colors::OwoColorize;
use crate::builder::Builder;
use crate::builder::RunConfig;
use crate::builder::Step;
Expand Down Expand Up @@ -67,7 +67,7 @@ fn build_testsuite_tool(builder: &Builder<'_>) {
);
command.env("RUSTFLAGS", rustflags);

println!("INFO: Building testsuite tool before running tests");
println!("{} Building testsuite tool before running tests", "info:".bold());
let status = command.status().expect("failed to get status");
if !status.success() {
exit(status.code().unwrap_or(1));
Expand Down Expand Up @@ -103,7 +103,7 @@ fn run_ui_tests(builder: &Builder<'_>) {
command.args(&builder.config.subcommand_args);
command.current_dir(&builder.config.root);

println!("INFO: Running testsuite tool");
println!("{} Running testsuite tool", "info:".bold());
let status = command.status().expect("failed to get status");
if !status.success() {
exit(status.code().unwrap_or(1));
Expand Down
2 changes: 1 addition & 1 deletion tools/testsuite/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn make_test(config: Arc<Config>, path: PathBuf) -> Option<TestDescAndFn> {

let Ok(header) = header::parse_header(&path) else {
eprintln!(
"WARN: test file {} does not have a valid test file header, ignoring",
"{} test file {} does not have a valid test file header, ignoring",
path.display()
);
return None;
Expand Down
Loading