[PATCH v2 2/2] Introduce conf/config.dev for development

Frédéric Mangano-Tarumi fmang at mg0.fr
Tue Jun 2 12:41:28 UTC 2020


Lukas Fleischer [2020-06-01 21:05:57 -0400]
> On Mon, 01 Jun 2020 at 12:50:23, Frédéric Mangano-Tarumi wrote:
> > diff --git a/conf/config.dev b/conf/config.dev
> > new file mode 100644
> > index 00000000..e9c2112e
> > --- /dev/null
> > +++ b/conf/config.dev
> > @@ -0,0 +1,36 @@
> > +; Configuration file for aurweb development.
> > +;
> > +; Options are implicitly inherited from ${AUR_CONFIG}.defaults, which lists all
> 
> Saying ${AUR_CONFIG}.defaults here is elegant, short, precise and clear
> to everybody who is familiar with the code base. However, given that
> those comments are mainly relevant to new contributors setting up a dev
> environment, I am not sure whether mentioning $AUR_CONFIG is a good idea
> here (people might not be aware of what exactly it is used for at this
> point). How about just saying config.defaults, given that the file is in
> the same directory? While being less precise, most people should still
> understand which file is referred to.

Developers need to set AUR_CONFIG to spawn aurweb. If we introduced it
earlier like “Define the path to you configuration:
export AUR_CONFIG="…"”, I think it should fit.

As you implied though, using anything other than conf/config is madness.
How about making aurweb.spawn set AUR_CONFIG to, by order of preference:

1. $AUR_CONFIG, if already defined,
2. $PWD/conf/config, if it exists,
3. $parent/conf/config where $parent is the nearest parent directory
   such that the file exists.

aurweb.spawn is only meant for development, and it spawns test servers,
so I think it makes sense to use a different default for AUR_CONFIG than
production.

> > +; available options for productions, and their default values. This current file
> > +; overrides only options useful for development, and introduces
> > +; development-specific options too.
> > +;
> > +; Paths need to be absolute, so please replace $AUR_ROOT with your project root.
> 
> Even though you added a comment is here, I am not sure that using
> $AUR_ROOT below is a great idea since it is too easy to skip part of the
> comment and then think that $AUR_ROOT is an actual placeholder parsed by
> aurweb. I would either go back to putting a sensible default path
> everywhere or replicate this comment directly above all lines containing
> $AUR_ROOT.

I considered using relative paths, but because PHP changes the working
directory and Python doesn’t, that can’t work. Nor can we have a
sensible absolute path for everyone, since we cannot tell where the
developer cloned the project.

I can replace $AUR_ROOT by YOUR_AUR_ROOT, which is more explicit, and
remove the comment. In TESTING, we can suggest using the following
command:
	sed -e "s;YOUR_AUR_ROOT;$PWD;g" conf/config.dev > conf/config

With more motivation, we could add support for environment variable
interpolation in INI files. aurweb.config would know AUR_ROOT as a
by-product of finding AUR_CONFIG, if we implement that.

> > +
> > +[database]
> > +
> 
> Stray newline?
> 
> > +backend = sqlite
> > +name = $AUR_ROOT/aurweb.sqlite3
> > +
> > +; Alternative MySQL configuration
> > +;backend = mysql
> > +;name = aurweb
> > +;user = aur
> > +;password = aur

I meant it to make the SQLite block stand out next to MySQL, but it does
look special compared to other sections.

In config.defaults, we use newlines only between sections, but that
doesn’t leave much room for documentation. Interleaving comments with
variables like I did below is okay only because the section is tiny. If
the file grew bigger, I wish the norm was “block of documentation + set
of correlated variable definitions + new line”. Sections would need a
special comment to make them visible, like a ruler or a frame.

> > +[php]
> > +; Address PHP should bind when spawned in development mode by aurweb.spawn.
> > +bind_address = 127.0.0.1:8081
> > +; Directory containing aurweb's PHP code, required by aurweb.spawn.
> > +htmldir = $AUR_ROOT/web/html

> > +; vim: ft=dosini
> 
> I think we usually don't add modelines or any other editor-specific
> configuration.

Ok!


More information about the aur-dev mailing list