Mercurial > sci
changeset 66:5076be758687 0.1.0
misc: update before 0.1.0 release
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 20 Aug 2022 10:36:55 +0200 |
parents | 471410c90954 |
children | 993798990ab8 |
files | CHANGES.md Makefile README.md man/sci.7 man/scictl.8 man/scid.8 man/sciworkerd.8 scid/db.c scid/scid.c |
diffstat | 9 files changed, 164 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CHANGES.md Sat Aug 20 10:36:55 2022 +0200 @@ -0,0 +1,7 @@ +sci CHANGES +=========== + +sci 0.1.0 2022-08-20 +-------------------- + +- Initial development release.
--- a/Makefile Thu Aug 18 20:21:33 2022 +0200 +++ b/Makefile Sat Aug 20 10:36:55 2022 +0200 @@ -104,7 +104,7 @@ SCIWORKERD_DEPS= ${SCIWORKERD_SRCS:.c=.d} MAN7= sci.7 -MAN8= scid.8 sciworkerd.8 +MAN8= scictl.8 scid.8 sciworkerd.8 TESTS= tests/test-db.c TESTS_OBJS= ${TESTS:.c=} @@ -119,6 +119,7 @@ -I. DEFS= -DVARDIR=\"${VARDIR}\" \ -DVERSION=\"${VERSION}\" \ + -DSHAREDIR=\"${SHAREDIR}\" \ -DSQLITE_THREADSAFE=0 \ -DSQLITE_OMIT_LOAD_EXTENSION=0 \ -DSQLITE_OMIT_DEPRECATED=0 \ @@ -196,6 +197,8 @@ for m in ${MAN8}; do \ sed ${SUBST} < man/$$m > ${DESTDIR}${MANDIR}/man8/$$m; \ done + mkdir -p ${DESTDIR}${SHAREDIR}/sci + cp -R themes ${DESTDIR}${SHAREDIR}/sci clean: rm -f extern/bcc/bcc tags cscope.out ${MAN7} ${MAN8} ${SQL_OBJS}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Sat Aug 20 10:36:55 2022 +0200 @@ -0,0 +1,15 @@ +sci +=== + +This is sci, a minimalist continous integration system written in C11. + +Documentation +------------- + +See `sci(7)` manual page for a quick overview or utilities defined in their own +manual pages: `scid(8)`, `scictl(8)`, `sciworkerd(8)`. + +Author +------ + +David Demelier <markand@malikania.fr>
--- a/man/sci.7 Thu Aug 18 20:21:33 2022 +0200 +++ b/man/sci.7 Sat Aug 20 10:36:55 2022 +0200 @@ -45,8 +45,9 @@ o ---- scictl / scid (HTTP) o - \\ - o ---- sciworkerd + | \\ + | o ---- sciworkerd + SQLite .Ed .Pp The @@ -68,7 +69,7 @@ and output their result. .\" ENTITIES .Sh ENTITIES -The process handle different kind of entities in the database. +The process handles different kind of entities in the database. .\" PROJECTS .Ss PROJECTS A project is a user description of what to be automated and tested. It has a @@ -131,13 +132,88 @@ require to perform requests. Use the .Cm api-get command to get that key. +.Pp +The +.Xr scid 8 +program isn't a daemon by itself but a CGI or FastCGI process which needs to be +coupled with a dedicated web server. For the example let's use nginx and the +.Xr kfcgi 8 +utility to spawn our FastCGI process. +.Pp +Configure the nginx server to include at least the following code snippet for a +specific virtual host (the +.Xr scid 8 +process explicitly requires its own virtual host). .Bd -literal -offset indent -$ scid -Or -$ scid -d /var/db/scid.db +server { + server_name sci.myhostname.fr; + listen 80; + + location / { + fastcgi_param QUERY_STRING query_string; + fastcgi_param REQUEST_METHOD $request_method; + fastcgi_param CONTENT_TYPE $content_type; + fastcgi_param CONTENT_LENGTH $content_length; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_NAME $fastcgi_script_name; + fastcgi_param PATH_INFO $document_uri; + fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; + fastcgi_param REQUEST_URI $request_uri; + fastcgi_param DOCUMENT_URI $document_uri; + fastcgi_param DOCUMENT_ROOT $document_root; + fastcgi_param SERVER_PROTOCOL $server_protocol; + fastcgi_param GATEWAY_INTERFACE CGI/1.1; + fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; + fastcgi_param REMOTE_ADDR $remote_addr; + fastcgi_param REMOTE_PORT $remote_port; + fastcgi_param SERVER_ADDR $server_addr; + fastcgi_param SERVER_PORT $server_port; + fastcgi_param SERVER_NAME $server_name; + fastcgi_param HTTPS $https; + fastcgi_pass unix:/var/www/run/httpd.sock; + } +} .Ed .Pp -Retrieve the stored key: +Now, start the process using +.Xr kfcgi 8 . +It is recommended though, that the process lives in a clean chroot but in the +example we will skip that because +.Xr scid 8 +cannot be built as static binary yet, you could as an alternative setup a +chroot where all required libraries are available in order to run +.Xr scid 8 +inside of it. +.Pp +We will assume that the webserver is running with +.Em www +user and group which is the default also used with +.Xr kfcgi 8 +utility. The webserver must have read/write access to the UNIX socket generated +with +.Xr kfcgi 8 . +.Pp +This command needs to be ran as root but it will drop privileges to +appropriate users and groups. See +.Xr kfcgi 8 +for more details. +.Bd -literal -offset indent +# kfcgi -p / -- scid -f +Or +# kfcgi -p / -u www -U www -- scid -f -d /path/to/sci.db -t /path/to/theme +Or if you have a functional chroot (scid path is relative to it) +# kfcgi -p /srv/sci -- /usr/bin/scid -f +.Ed +.Pp +Make sure that +.Xr scid 8 +get read/write access to the default database path if you're not using the +.Fl d +option. Also don't forget the +.Fl f +option which indicates the process to run as FastCGI rather than plain CGI. +.Pp +If the command succeeded, Retrieve the stored key: .Bd -literal -offset indent $ scid api-get 1234567890secretABCDEF @@ -181,8 +257,8 @@ script code remotely! .Bd -literal -offset indent $ sciworkerd -Or -$ sciworkerd -j2 +Or more secure alternative +# chroot /src/sci /usr/bin/sciworkerd -j2 .Ed .Pp Please make sure to read @@ -216,7 +292,12 @@ .Pp And after that, any .Xr sciworkerd 8 -instance will fetch the job, run it and send the result. +instance will fetch the job, run it and send the result. It is best used with +your SCM to add automatic job when pushing changes. +.Pp +Note: Jobs that are created before the registration of a worker won't be +executed as it would create a high number of jobs to be performed each time you +create a new worker. .\" SEE ALSO .Sh SEE ALSO .Xr scictl 8 ,
--- a/man/scictl.8 Thu Aug 18 20:21:33 2022 +0200 +++ b/man/scictl.8 Sat Aug 20 10:36:55 2022 +0200 @@ -107,16 +107,16 @@ .\" job-todo .It Cm job-todo List jobs that must be performed by the given -.Ar worker . -Jobs that were created earlier than the worker will not be listed to avoid -evaluating a possible high number of jobs. +.Ar worker +name. Jobs that were created earlier than the worker will not be listed to +avoid evaluating a possible high number of jobs. .\" project-add .It Cm project-add Create a new project with .Ar name , -an user description set with +a user description set with .Ar desc , -a website arbitrary +an arbitrary website .Ar url , and a script code to execute specified by file .Ar script . @@ -149,12 +149,6 @@ .Ar name argument and a new description as .Ar key . -.Pp -Examples: -.Bd -literal -offset indent -scictl project-update example desc "New description" -scictl project-update example script "/path/to/script.sh" -.Ed .\" worker-add .It Cm worker-add Create a new worker with @@ -182,6 +176,29 @@ .It Ev SCI_API_KEY Secret API key to perform requests. .El +.\" EXAMPLES +.Sh EXAMPLES +Add a new worker named OpenBSD with identifier openbsd +.Bd -literal -offset indent +$ scictl worker-add openbsd OpenBSD +.Ed +.Pp +Add a project hello that executes a script shell. +.Bd -literal -offset indent +$ scictl project add hello "Hello World" http://hello.org hello.sh +.Ed +.Pp +Add a new job for the project hello with as argument +.Dq world +.Bd -literal -offset indent +$ scictl job-add hello world +.Ed +.Pp +Update the project hello with new description and new code +.Bd -literal -offset indent +scictl project-update example desc "Hello World v2"" +scictl project-update example script hello2.sh +.Ed .\" SEE ALSO .Sh SEE ALSO .Xr sci 7 ,
--- a/man/scid.8 Thu Aug 18 20:21:33 2022 +0200 +++ b/man/scid.8 Sat Aug 20 10:36:55 2022 +0200 @@ -45,7 +45,7 @@ .Pp Usually, you want to setup .Nm -to run with the associated too +to run with the associated tool .Xr kfcgi 8 or any other FastCGI spawner. .Pp
--- a/man/sciworkerd.8 Thu Aug 18 20:21:33 2022 +0200 +++ b/man/sciworkerd.8 Sat Aug 20 10:36:55 2022 +0200 @@ -62,7 +62,7 @@ .It Fl t Ar timeout Defines in seconds the .Ar timeout -before a job will be killed. +before a job will be killed. Default: 600 seconds. .It Fl u Set the .Ar url @@ -97,6 +97,17 @@ .It Ev SCI_WORKER Defines the worker name to connect as. .El +.\" EXAMPLES +.Sh EXAMPLES +Register as openbsd worker +.Bd -literal -offset indent +$ sciworkerd -w openbsd +.Ed +.Pp +Run with maximum of four tasks in parallel with a timeout of five minutes +.Bd -literal -offset indent +$ sciworkerd -j 4 -t 300 +.Ed .\" SEE ALSO .Sh SEE ALSO .Xr sci 7 ,
--- a/scid/db.c Thu Aug 18 20:21:33 2022 +0200 +++ b/scid/db.c Sat Aug 20 10:36:55 2022 +0200 @@ -365,13 +365,13 @@ assert(path); if (sqlite3_open(path, &db) != SQLITE_OK) - return log_warn("db: open error: %s", sqlite3_errmsg(db)), -1; + return log_warn("db: %s: %s", path, sqlite3_errmsg(db)), -1; /* Wait for 30 seconds to lock the database. */ sqlite3_busy_timeout(db, 30000); if (sqlite3_exec(db, CHAR(sql_init), NULL, NULL, NULL) != SQLITE_OK) - return log_warn("db: initialization error: %s", sqlite3_errmsg(db)), -1; + return log_warn("db: %s: initialization error: %s", path, sqlite3_errmsg(db)), -1; return 0; }
--- a/scid/scid.c Thu Aug 18 20:21:33 2022 +0200 +++ b/scid/scid.c Sat Aug 20 10:36:55 2022 +0200 @@ -25,6 +25,7 @@ #include "theme.h" struct scid scid = { + .themedir = SHAREDIR "/sci/themes/bulma", .dbpath = VARDIR "/db/sci/sci.db" }; @@ -37,8 +38,10 @@ static void init_database(void) { + log_info("scid: opening database %s", scid.dbpath); + if (db_open(scid.dbpath) < 0) - log_die("scid: unable to open database"); + exit(1); /* Retrieve or create the API key if not existing. */ switch (db_key_get(scid.apikey, sizeof (scid.apikey))) {