diff --git a/db/db-core/src/lib.rs b/db/db-core/src/lib.rs index 457189e..d54123c 100644 --- a/db/db-core/src/lib.rs +++ b/db/db-core/src/lib.rs @@ -182,13 +182,13 @@ pub trait SCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase { /// delete DNS challenge async fn delete_dns_challenge(&self, key: &str) -> DBResult<()>; - /// create forge isntance - async fn create_forge_isntance(&self, f: &CreateForge) -> DBResult<()>; + /// create forge instance + async fn create_forge_instance(&self, f: &CreateForge) -> DBResult<()>; - /// get forge isntance data + /// get forge instance data async fn get_forge(&self, hostname: &str) -> DBResult; - /// delete forge isntance + /// delete forge instance async fn delete_forge_instance(&self, hostname: &str) -> DBResult<()>; /// check if a forge instance exists diff --git a/db/db-core/src/tests.rs b/db/db-core/src/tests.rs index eb3ee3a..e3c150f 100644 --- a/db/db-core/src/tests.rs +++ b/db/db-core/src/tests.rs @@ -27,10 +27,10 @@ pub async fn adding_forge_works<'a, T: SCDatabase>( add_repo_msg: AddRepository<'a>, ) { let _ = db.delete_forge_instance(create_forge_msg.hostname).await; - db.create_forge_isntance(&create_forge_msg).await.unwrap(); + db.create_forge_instance(&create_forge_msg).await.unwrap(); assert!( db.forge_exists(create_forge_msg.hostname).await.unwrap(), - "forge creation failed, forge existance check failure" + "forge creation failed, forge exinstance check failure" ); { diff --git a/db/db-sqlx-sqlite/src/lib.rs b/db/db-sqlx-sqlite/src/lib.rs index 8e6ec68..1864bca 100644 --- a/db/db-sqlx-sqlite/src/lib.rs +++ b/db/db-sqlx-sqlite/src/lib.rs @@ -111,7 +111,7 @@ impl SCDatabase for Database { } } - /// delete forge isntance + /// delete forge instance async fn delete_forge_instance(&self, hostname: &str) -> DBResult<()> { sqlx::query!( "DELETE FROM starchart_forges WHERE hostname = ($1)", @@ -123,8 +123,8 @@ impl SCDatabase for Database { Ok(()) } - /// create forge isntance DB - async fn create_forge_isntance(&self, f: &CreateForge) -> DBResult<()> { + /// create forge instance DB + async fn create_forge_instance(&self, f: &CreateForge) -> DBResult<()> { let now = now_unix_time_stamp(); let forge_type = f.forge_type.to_str(); sqlx::query!( @@ -142,7 +142,7 @@ impl SCDatabase for Database { Ok(()) } - /// get forge isntance data + /// get forge instance data async fn get_forge(&self, hostname: &str) -> DBResult { let f = sqlx::query_as!( InnerForge, diff --git a/docs/HACKING.md b/docs/HACKING.md index b867ec4..7c6125a 100644 --- a/docs/HACKING.md +++ b/docs/HACKING.md @@ -32,9 +32,38 @@ project.** curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` +### Setting up the workspace +After installing rust, the database schema needs to be migrated, +we use `sqlx` in this project to handle this. However, before running +this application you might end up finding yourself stuck, here are a +few things that you might come across. + +#### Environment variables +> thread 'main' panicked at 'called `Result::unwrap()` on an `Err` +> value: missing field `url`' + +Please ensure that you have the `.env` stored in the root of the +repository, you can copy this from the `.env-sample` present in +the root of the repository. + +[temporary fix] There is also a need for the `DATABASE_URL` to +be defined, so add that in too. + +Next up, run the following commands to have the project compile and run, +```bash +source .env +make migrate +make +``` + +This should ideally get your instance of Starchart running, and if +you face any issues at this point, it's a good idea to check your +environment variables once more, and review the dependencies for +the project. + ## Implementing Support for $FORGE -> In future, Starchart will be modified to talk forge federation +> In the future, Starchart will be modified to talk forge federation > ActivityPub protocol(general term, not referring to > [forgefed](https://forgefed.peers.community/)), so implementing support > for $FORGE would mean implementing that protocol for $FORGE. diff --git a/federate/federate-core/src/lib.rs b/federate/federate-core/src/lib.rs index bad7f94..e1cd564 100644 --- a/federate/federate-core/src/lib.rs +++ b/federate/federate-core/src/lib.rs @@ -36,10 +36,10 @@ pub trait Federate: Sync + Send { /// utility method to remove file/dir async fn rm_util(&self, path: &Path) -> Result<(), Self::Error>; - /// create forge isntance - async fn create_forge_isntance(&self, f: &CreateForge<'_>) -> Result<(), Self::Error>; + /// create forge instance + async fn create_forge_instance(&self, f: &CreateForge<'_>) -> Result<(), Self::Error>; - /// delete forge isntance + /// delete forge instance async fn delete_forge_instance(&self, hostname: &str) -> Result<(), Self::Error>; /// check if a forge instance exists @@ -48,10 +48,10 @@ pub trait Federate: Sync + Send { /// check if an user exists. async fn user_exists(&self, username: &str, hostname: &str) -> Result; - /// create user isntance + /// create user instance async fn create_user(&self, f: &AddUser<'_>) -> Result<(), Self::Error>; - /// add repository isntance + /// add repository instance async fn create_repository(&self, f: &AddRepository<'_>) -> Result<(), Self::Error>; /// check if a repository exists. diff --git a/federate/federate-core/src/tests.rs b/federate/federate-core/src/tests.rs index df9a268..c8f1ea8 100644 --- a/federate/federate-core/src/tests.rs +++ b/federate/federate-core/src/tests.rs @@ -27,7 +27,7 @@ pub async fn adding_forge_works<'a, T: Federate>( ) { let _ = ff.delete_forge_instance(create_forge_msg.hostname).await; assert!(!ff.forge_exists(&create_forge_msg.hostname).await.unwrap()); - ff.create_forge_isntance(&create_forge_msg).await.unwrap(); + ff.create_forge_instance(&create_forge_msg).await.unwrap(); assert!(ff.forge_exists(&create_forge_msg.hostname).await.unwrap()); // add user diff --git a/federate/publiccodeyml/src/lib.rs b/federate/publiccodeyml/src/lib.rs index e713cca..63081e7 100644 --- a/federate/publiccodeyml/src/lib.rs +++ b/federate/publiccodeyml/src/lib.rs @@ -128,14 +128,14 @@ impl Federate for PccFederate { Ok(()) } - /// create forge isntance - async fn create_forge_isntance(&self, f: &CreateForge<'_>) -> FResult<()> { + /// create forge instance + async fn create_forge_instance(&self, f: &CreateForge<'_>) -> FResult<()> { let path = self.get_instance_path(f.hostname, true).await?; self.write_util(f, &path.join(INSTANCE_INFO_FILE)).await?; Ok(()) } - /// delete forge isntance + /// delete forge instance async fn delete_forge_instance(&self, hostname: &str) -> FResult<()> { let path = self.get_instance_path(hostname, false).await?; self.rm_util(&path).await @@ -163,13 +163,13 @@ impl Federate for PccFederate { } } - /// create user isntance + /// create user instance async fn create_user(&self, f: &AddUser<'_>) -> Result<(), Self::Error> { let path = self.get_user_path(f.username, f.hostname, true).await?; self.write_util(f, &path.join(USER_INFO_FILE)).await } - /// add repository isntance + /// add repository instance async fn create_repository(&self, f: &AddRepository<'_>) -> Result<(), Self::Error> { let path = self .get_repo_path(f.name, f.owner, f.hostname, true) diff --git a/scripts/gitea.py b/scripts/gitea.py index 7fa229e..5f4e827 100755 --- a/scripts/gitea.py +++ b/scripts/gitea.py @@ -193,11 +193,11 @@ def add_tag(repo: str, client: HTMLClient): if __name__ == "__main__": for i in range(TOTAL_NUM_REPOS): - REPOS.append(f"reopsitory_{i}") + REPOS.append(f"repository_{i}") check_online() - print("Instace online") + print("Instance online") install() - print("Instace configured and installed") + print("Instance configured and installed") client = HTMLClient() count = 0 while True: diff --git a/src/main.rs b/src/main.rs index d2a8a29..51894ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,7 @@ pub mod routes; pub mod settings; pub mod spider; pub mod static_assets; + #[cfg(test)] mod tests; pub mod utils; diff --git a/src/spider.rs b/src/spider.rs index ff9a925..925ceac 100644 --- a/src/spider.rs +++ b/src/spider.rs @@ -44,7 +44,7 @@ impl Ctx { hostname, forge_type: forge.forge_type(), }; - db.create_forge_isntance(&msg).await.unwrap(); + db.create_forge_instance(&msg).await.unwrap(); } else { if !federate.forge_exists(hostname).await.unwrap() { let forge = db.get_forge(hostname).await.unwrap(); @@ -52,7 +52,7 @@ impl Ctx { hostname, forge_type: forge.forge_type, }; - federate.create_forge_isntance(&msg).await.unwrap(); + federate.create_forge_instance(&msg).await.unwrap(); } } @@ -142,7 +142,7 @@ mod tests { .unwrap()); assert!(db.user_exists(GITEA_USERNAME, None).await.unwrap()); for i in 0..100 { - let repo = format!("reopsitory_{i}"); + let repo = format!("repository_{i}"); assert!(db .repository_exists(&repo, GITEA_USERNAME, hostname.as_str()) .await