purescript / registry-dev

Development work related to the PureScript Registry
https://github.com/purescript/registry
97 stars 80 forks source link

Ensure scripts use the root for cache, scratch, env files #532

Closed thomashoneyman closed 1 year ago

thomashoneyman commented 1 year ago

@f-f The various CI jobs are currently failing because the scripts and registry-api utility expect to be executed from the root of the repository (for example, DotEnv.loadFile expects there to be a .env file in the current directory; we also expect the current directory to contain the scratch dir, .cache directory, and so on). However, in the new monorepo setup Spago is executing in the context of the individual packages so the paths are no longer correct.

I've fixed this by ensuring that we refer to the scratch, .cache directories and the .env file in their proper location (the root). However, question for you: to get to the root I'm having to do ../../, but I would expect Spago to execute with the cwd being the directory containing the spago.yaml file. Is this expected? If not, it's an easy change on our side (just change rootDir).

thomashoneyman commented 1 year ago

If you check before this change you'll see that attempting to read the Dhall directory fails (incorrect path); attempting to read the .env file fails silently (you just get a "not found" for each env variable in it rather than an outright crash); you'll see that the scratch dir is incorrectly created in the various script directories.

thomashoneyman commented 1 year ago

I think for the time being I'd prefer to unify the scripts in the scripts dir to be one package and run it with -m. Open to other things for the long term. What do you think?

f-f commented 1 year ago

Note that this implies that the API module would end up there too (so option 1 is very similar to option 3), I was under the impression that you wanted to have that separate from the legacy scripts?

f-f commented 1 year ago

Ah well right, the scripts don't have to be together with the API module, it's enough that they are at the same level of nesting

f-f commented 1 year ago

So yeah, this sounds good to me!

thomashoneyman commented 1 year ago

Note that this implies that the API module would end up there too (so option 1 is very similar to option 3), I was under the impression that you wanted to have that separate from the legacy scripts?

If the scripts directory becomes:

...then that solves the problem because the nesting becomes even with the API.

thomashoneyman commented 1 year ago

Oh, I see you already commented that. Cool -- I'll go ahead with the change.