xaizek / fragile (License: AGPLv3+) (since 2018-12-07)
Simple lightweight CI, attempting to be somewhat Unix-like in its philosophy.
Commit 551c77ee56586a130266c225a9affa85b8d383a8

Add build start/end time fields to the database
Author: xaizek
Author date (UTC): 2018-11-24 12:12
Committer name: xaizek
Committer date (UTC): 2018-11-24 12:38
Parent(s): d0d3b1ce464daf8b2c4129e2c101e0a05a40d05a
Signing key: 99DC5E4DB05F6BE2
Tree: a80693db70d8de555a160e85ecdf45b5f575b443
File Lines added Lines deleted
INSTALL.md 4 3
classes/DB.php 54 25
File INSTALL.md changed (mode: 100644) (index cd895cc..673bc82)
... ... Run the `install` script to perform the installation:
43 43 install <web-path> <daemon-path> install <web-path> <daemon-path>
44 44
45 45 Start the daemon and it will create database, web-interface will create it too, Start the daemon and it will create database, web-interface will create it too,
46 but only if it has corresponding permissions.
46 but only if it has necessary permissions.
47 47
48 48 ### Managing builders ### ### Managing builders ###
49 49
 
... ... hooks (this is for Git, other VCSs might differ).
82 82
83 83 ### Updates ### ### Updates ###
84 84
85 Don't forget to remove database before an update to address possible changes of
86 tables.
85 Database is upgraded in place automatically, consider backing it up if
86 necessary. It can be upgraded on any access to it, but normally only daemon
87 will have write permissions on it.
File classes/DB.php changed (mode: 100644) (index 32f1d1c..9802e38)
... ... class DB
49 49 * @returns DB instance. * @returns DB instance.
50 50 */ */
51 51 private static function getInstance() { private static function getInstance() {
52 if (!self::$objInstance) {
53 self::$objInstance = new PDO(DB_DSN);
54 self::$objInstance->setAttribute(PDO::ATTR_ERRMODE,
55 PDO::ERRMODE_EXCEPTION);
56 self::$objInstance->exec(<<<EOS
57 CREATE TABLE IF NOT EXISTS buildsets (
58 buildsetid INTEGER,
59 name TEXT NOT NULL,
60 revision TEXT NOT NULL,
61 timestamp INTEGER,
62
63 PRIMARY KEY (buildsetid)
64 );
65
66 CREATE TABLE IF NOT EXISTS builds (
67 buildset INTEGER,
68 buildername TEXT NOT NULL,
69 output BLOB NOT NULL,
70 status TEXT NOT NULL,
71 exitcode INTEGER,
72
73 PRIMARY KEY (buildset, buildername),
74 FOREIGN KEY (buildset) REFERENCES buildsets(buildsetid)
75 );
52 if (self::$objInstance) {
53 return self::$objInstance;
54 }
55
56 self::$objInstance = new PDO(DB_DSN);
57 self::$objInstance->setAttribute(PDO::ATTR_ERRMODE,
58 PDO::ERRMODE_EXCEPTION);
59
60 $statement = self::$objInstance->query('pragma user_version');
61 if (!$statement) {
62 die("Failed to query user version from the database\n"
63 . print_r(DB::errorInfo(), true));
64 }
65
66 $userVersion = $statement->fetch();
67 if ($userVersion === false) {
68 die("Failed to fetch user version from the database\n"
69 . print_r(DB::errorInfo(), true));
70 }
71 $version = $userVersion[0];
72 if ($version == 1) {
73 return self::$objInstance;
74 }
75
76 switch ($version) {
77 case 0:
78 self::$objInstance->exec(<<<EOS
79 CREATE TABLE IF NOT EXISTS buildsets (
80 buildsetid INTEGER,
81 name TEXT NOT NULL,
82 revision TEXT NOT NULL,
83 timestamp INTEGER,
84
85 PRIMARY KEY (buildsetid)
86 );
87
88 CREATE TABLE IF NOT EXISTS builds (
89 buildset INTEGER,
90 buildername TEXT NOT NULL,
91 output BLOB NOT NULL,
92 status TEXT NOT NULL,
93 exitcode INTEGER,
94
95 PRIMARY KEY (buildset, buildername),
96 FOREIGN KEY (buildset) REFERENCES buildsets(buildsetid)
97 );
98
99 ALTER TABLE builds ADD COLUMN starttime INTEGER DEFAULT 0;
100 ALTER TABLE builds ADD COLUMN endtime INTEGER DEFAULT 0;
76 101 EOS EOS
77 102 ); );
78
103 // Fall through.
104 case 1:
105 break;
79 106 } }
80 107
108 self::$objInstance->exec('pragma user_version = 1');
109
81 110 return self::$objInstance; return self::$objInstance;
82 111 } }
83 112
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/fragile

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/fragile

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master