Split code into cargo workspaces #67
Loading…
Reference in New Issue
No description provided.
Delete Branch "workspaces"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
It looks like clean build time increased a lot since we merged the federation branch. In my test it took 2:20 minutes. This PR decreases it to 1:28.
Still need to fix the tests.
Some more things to try:
Fixed the test imports, but tests are still failing because the relative path
config/defaults.hjson
is not correct. I guess the best fix would be to make it so that tests dont need those files at all.Note that tests need to be run with
cargo test --all
now, and format withcargo fmt --all
.Edit:: Not sure if this PR in its current state actually speeds things up, seeing 108s on master and 103s on this branch.
WIP: split code into cargo workspacesto split code into cargo workspacessplit code into cargo workspacesto Split code into cargo workspaces@dessalines Fixed the tests, rebased and ready to review. The first commit just moves files around and changes imports, so its much more important to review the second commit. In particular:
To be clear, even though this doesnt improve compilation time, I still think its very useful to merge this, as it makes for better separation of the code into mostly independent units.
I'll test / review this later today, but ya I don't wanna merge anything that breaks the tests, that's gotta be figured out.
I think all thats needed is writing a migration for
activity.data
, converting it to TEXT. Based on this error:ERROR: column "data" is of type jsonb but expression is of type text at character 76
.I tried the following byt its not working:
Looks good, I'm guessing the tests are failing due to the activity jsonb column stuff.
Also I'm not sure why but the
docker-compose.yml
s are all broken.@ -8,3 +8,3 @@
```bash
psql -U lemmy -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
export DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy
export LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy
This does need to be
DATABASE_URL
, because that's what diesel needs to run the migrations.@ -0,0 +1,15 @@
[package]
name = "lemmy_db"
version = "0.1.0"
authors = ["Felix Ableitner <me@nutomic.com>"]
add me too plz
Of course, this is just what it auto-generated. Tbh I'm not sure its a good idea to have my email listed there in plaintext. Maybe we should put
dev@lemmy.ml
or something like that?Ya, sounds good.
@ -0,0 +76,4 @@
pub fn update_ap_id(
conn: &PgConnection,
comment_id: i32,
apub_id: String,
Ah I see, this got moved to the other workspace.
Yep it was one of the few apub things in the database, so it seemed cleaner to remove the apub dependency from the db.
@ -0,0 +124,4 @@
}
pub fn get_database_url_from_env() -> Result<String, VarError> {
env::var("LEMMY_DATABASE_URL")
Is there any way to import the settings here? This is less than ideal bc if we ever reformat the settings
hjson
, we'll have to track this down at run-time.Then I would probably have to make a separate workspace just for settings. This way seems much cleaner because we want things to be in parallel as much as possible.
But I will add a comment about that or something.
Ya, a comment is good enough for now. Surprising that the settings doesn't get used in both of these.
Actually I thought I removed the check of
LEMMY_DATABASE_URL
in settings, thats not needed. Will get rid of that, soDATABASE_URL
here in db will be the only env var for that.@ -0,0 +2,4 @@
activity (id) {
id -> Int4,
user_id -> Int4,
data -> Text,
I don't think you can just overwrite it like that, and either way it gets re-written every time you run a migration.
@ -0,0 +1,23 @@
[package]
name = "lemmy_utils"
version = "0.1.0"
authors = ["Felix Ableitner <me@nutomic.com>"]
same
@ -0,0 +70,4 @@
let claims: Claims = Claims::decode(&jwt).expect("Invalid token").claims;
User_::read(&conn, claims.id)
}
}
This does make sense to be split out. Soon I'm gonna remove almost all this stuff from the jwt, and just pull it, in order to make the settings more portable.
Updated. See the last commit for details.
However,
test_mentions_regex
is failing, becauseWEBFINGER_COMMUNITY_REGEX
reads a field from settings. Problem is that during tests, the pathconfig/defaults.hjson
is interpreted as relative to the lemmy_utils folder, meaning it tries to read fromserver/lemmy_utils/config/defaults.hjson
(which doesnt exist). So either we need to make it so the test doesnt read from settings, or we add another config file in that location.Federation tests are fixed, except "create test comment" is failing for some reason (I will investigate later).
I also had to change all occurences of
LEMMY_DATABASE_URL
toDATABASE_URL
, which is a breaking change. I could also add a check for the old env var to stay backwards compatible.Can't we just move these two below up a dir? Or make sure its possible to run the utils tests from the parent dir. Or possibly symlinks might work.
That shouldn't be necessary, its fine as it was. DATABASE_URL is something that only diesel needs.
Also all the docker builds fail w/ this:
Should be good now, all tests are passing (including federation). Please consider squashing before merging.