2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/guix-cuirass.git synced 2024-12-29 11:40:16 +01:00
Commit graph

1356 commits

Author SHA1 Message Date
Romain GARBAGE
e1a4675ec4
tests: Test properties in specifications.
* tests/common.scm (specifications=?): Add testing of the properties field.
* tests/forgejo.scm (default-pull-request-json): Add missing fields.
(test): Add properties to expected specification.
* tests/gitlab.scm (default-mr-json, custom-mr-json,
custom-mr-json-multiple-packages, custom-mr-json-name-prefix,
custom-mr-json-build-all): Fix iid type. Add missing fields. Improve coherency
of values.
(tests): Add properties to expected specifications.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-26 18:56:17 +01:00
Ludovic Courtès
f9c951d95d
templates: Display pull-request info on evaluation build page.
* src/cuirass/templates.scm (evaluation-build-table): Add #:properties.
Add call to ‘pull-request-info-box’.
* src/cuirass/http.scm (evaluation-html-page): Pass #:properties to
‘evaluation-build-table’.
2024-12-26 15:07:26 +01:00
Ludovic Courtès
b68a22dad6
templates: Really distinguish pull requests in spec list.
This is a followup to 774113d13b.

* src/cuirass/templates.scm (specifications-table): Move
“text-secondary”/“text-primary” class to the ‘a’ tag instead of ‘td’.
2024-12-26 15:02:52 +01:00
Ludovic Courtès
13737f2e15
templates: Add missing unquote for pull request info box.
* src/cuirass/templates.scm (pull-request-info-box): Add missing
unquote.
2024-12-26 14:57:00 +01:00
Ludovic Courtès
774113d13b
templates: Distinguish pull requests from other jobsets in spec list.
* src/cuirass/templates.scm (specifications-table)[pull-request?]: New
procedure.
Use it to select the class of specification name cells.
2024-12-20 22:46:19 +01:00
Ludovic Courtès
30dabb697c
templates: Display pull-request info on jobset dashboards.
* src/cuirass/templates.scm (evaluation-dashboard): Add ‘spec’.  Call
‘pull-request-info-box’.
* src/cuirass/http.scm (dashboard-page): Pass ‘spec’ to
‘evaluation-dashboard’.
2024-12-20 22:34:45 +01:00
Ludovic Courtès
47d8ca44ed
templates: Display pull-request info on jobset page.
* src/cuirass/http.scm (url-handler) </jobset/NAME>: Pass #:properties
to ‘evaluation-info-table’.
* src/cuirass/templates.scm (evaluation-info-table): Add #:properties.
Add call to ‘pull-request-info-box’.
(pull-request-info-box): New procedure.
2024-12-20 22:10:39 +01:00
Ludovic Courtès
ff60e7b83c
forgejo: Add provenance properties to pull request specs.
* src/cuirass/forges/forgejo.scm (forgejo-pull-request->specification):
Add ‘properties’ field.
* tests/http.scm (forgejo-pull-request-json-open): Add “url”.
("/admin/forgejo/event creates a spec from a new pull request"): Test
properties.
2024-12-20 19:55:34 +01:00
Ludovic Courtès
ecdbdbc2aa
forgejo: Add ‘home-page’ field to repository.
* src/cuirass/forges/forgejo.scm (<forgejo-repository>)[home-page]: New
field.
* tests/http.scm (forgejo-pull-request-json-open): Add “html_url”.
2024-12-20 19:55:31 +01:00
Ludovic Courtès
ecf7e2f060
gitlab: Add provenance properties to merge request specs.
* src/cuirass/forges/gitlab.scm (gitlab-merge-request->specification):
Add ‘properties’ field.
* tests/http.scm ("/admin/gitlab/event creates a spec from a new merge request"):
Check properties.
(gitlab-merge-request-json-open)
(gitlab-merge-request-json-close): Change “iid” value to a number.
2024-12-20 19:55:26 +01:00
Ludovic Courtès
954889784d
gitlab: Add ‘target-branch’ and ‘target’ fields to merge requests.
* src/cuirass/forges/gitlab.scm (<gitlab-merge-request>)[target-branch]
[target]: New fields.
* tests/gitlab.scm (default-mr-json)
(custom-mr-json, custom-mr-json-multiple-packages)
(custom-mr-json-name-prefix, custom-mr-json-build-all): Add “target”
field.
* tests/http.scm (gitlab-merge-request-json-open)
(gitlab-merge-request-json-close): Add “target”.
2024-12-20 18:56:10 +01:00
Ludovic Courtès
a1c4eaca3c
gitlab: Merge <gitlab-source> into <gitlab-project>.
This is the same schema and in fact the same thing.

* src/cuirass/forges/gitlab.scm (<gitlab-source>): Remove.
(<gitlab-project>)[home-page, repository-url]: New fields.
(gitlab-merge-request->specification): Adjust accordingly.
* tests/gitlab.scm (default-mr-json, custom-mr-json-name-prefix): Add
source “homepage” field.
2024-12-20 18:47:45 +01:00
Ludovic Courtès
2895a08f73
gitlab: Capture the project and merge request URLs.
* src/cuirass/forges/gitlab.scm (<gitlab-project>)[http-url]: New field.
* src/cuirass/forges/gitlab.scm (<gitlab-merge-request>)[url]: New field.
* tests/gitlab.scm (default-mr-json): Add them.
2024-12-20 18:01:44 +01:00
Ludovic Courtès
ff7b58f62f
forgejo: Add ‘url’ to <forgejo-pull-request>.
* src/cuirass/forges/forgejo.scm (<forgejo-pull-request>)[url]: New
field.
* tests/forgejo.scm (default-pull-request-json): Add it.
2024-12-20 18:01:15 +01:00
Ludovic Courtès
946d6d51c0
database: Add ‘properties’ field for specifications.
* src/schema.sql (Specifications): Add ‘properties’ field.
* src/sql/upgrade-16.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/cuirass/database.scm (db-get-specifications): Read ‘properties’.
(db-add-or-update-specification): Write it.
* src/cuirass/specification.scm (<specification>)[properties]: New field.
* tests/database.scm (example-spec)[properties]: New field.
("db-get-specifications"): Check it.
* doc/cuirass.texi (Specifications, Database): Document it.
2024-12-20 14:24:58 +01:00
Ludovic Courtès
10d4e5bda8
base: Remove specification metrics when removing a jobset.
* src/cuirass/base.scm (remove-jobset): Call
‘db-remove-specification-metrics’.
2024-12-17 10:09:29 +01:00
Ludovic Courtès
57989060ef
metrics: Add ‘db-remove-specification-metrics’.
* src/cuirass/metrics.scm (db-remove-specification-metrics): New
procedure.
* tests/metrics.scm ("db-remove-specification-metrics"): New test.
2024-12-17 10:09:29 +01:00
Ludovic Courtès
96811bd72a
metrics: ‘db-get-metric’ returns #f if not found.
* src/cuirass/metrics.scm (db-get-metric): Remove #f if not found.
2024-12-17 10:09:29 +01:00
Ludovic Courtès
2b29471ef0
metrics: Distinguish specification names from other strings.
* src/cuirass/metrics.scm (define-symbol-validation)
(validate-field-type-value): New macros.
(<metric>)[field-type]: Add ‘sanitize’.
(%metrics): Change ‘field-type’ to ‘specification-name’ where appropriate.
2024-12-17 10:09:25 +01:00
Ludovic Courtès
8aecceed00
build: Delete cuirass/forges/*.go upon ‘make clean’.
* Makefile.am (CLEANFILES): Add $(nodist_forgesobject_DATA).
2024-12-16 15:18:38 +01:00
Ludovic Courtès
3665686d1e
register: Add ‘--build-expiry’.
* src/cuirass/base.scm (build-queue-cleaner, spawn-build-queue-cleaner):
New procedures.
* src/cuirass/scripts/register.scm (show-help, %options): Add
‘--build-expiry’.
(cuirass-register): Call ‘spawn-build-queue-cleaner’ to honor
‘--build-expiry’.
* doc/cuirass.texi (Invocation): Document it.
2024-12-16 10:45:17 +01:00
Ludovic Courtès
57bc09edec
database: Add ‘db-cancel-old-pending-builds’.
* src/cuirass/database.scm (db-cancel-old-pending-builds): New
procedure.
2024-12-16 10:37:51 +01:00
Romain GARBAGE
87b56c61a8
forges: Install forges submodules in the right place.
* Makefile.am (forgesmodulesdir, forgesobjectdir, dist_forgesmodule_DATA,
nodist_forgesobject_DATA): New variables
(dist_pkgmodule_DATA): Remove forges submodules.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-13 11:46:02 +01:00
Romain GARBAGE
c9be27bc68
http: Add admin/forgejo/event.
* src/cuirass/http.scm (url-handler): Add "/admin/forgejo/event".
* tests/http.scm: Add tests for the "/admin/forgejo/event" endpoint.
* doc/cuirass.texi: Reorganize "Interfacing Cuirass..." section. Add
documentation for the "/admin/forgejo/event" endpoint.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-13 10:17:57 +01:00
Romain GARBAGE
6cdb860a40
tests: Explicit Gitlab endpoint related variables.
* tests/http.scm: Rename mr-* variables to gitlab-merge-request-*.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-13 10:17:43 +01:00
Romain GARBAGE
2ddf685a27
forgejo: Add module for Forgejo JSON objects definition.
* Makefile.am: Add src/cuirass/forges/forgejo.scm and tests/forgejo.scm.
* src/cuirass/forges/forgejo.scm: Add <forgejo-repository>,
<forgejo-pull-request-event>, <forgejo-pull-request>,
<forgejo-repository-reference> and <forgejo-repo> record types.
(forgejo-pull-request->specification): New variable.
* tests/forgejo.scm: Add tests.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-13 10:17:37 +01:00
Romain GARBAGE
f359221399
forges: Define default values for specifications.
* src/cuirass/forges.scm (%default-jobset-options-period,
%default-jobset-options-priority, %default-jobset-options-systems): New
variables.
* src/cuirass/forges/gitlab.scm (gitlab-merge-request->specification),
tests/gitlab.scm: Change hardcoded values to variables defined in the forges
module.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-13 10:17:32 +01:00
Romain GARBAGE
294d50e413
forges: Add module for common forges utilities.
* Makefile.am: Update module list.
* src/cuirass/forges.scm: New module.
* src/cuirass/gitlab.scm: Moved to src/cuirass/forges/gitlab.scm.
* src/cuirass/http.scm, tests/gitlab.scm, tests/http.scm: Update module header.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-13 10:17:26 +01:00
Romain GARBAGE
51efb1380a
tests: Rename specifications-equal? procedure.
* tests/common.scm (specifications=?): New variable.
(specifications-equal?): Remove variable.
* tests/gitlab.scm: Use new variable name.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-13 10:17:20 +01:00
Romain GARBAGE
b9abd222cd
tests: Move procedure definition.
* tests/common.scm (specifications-equal?): New variable.
* tests/gitlab.scm (specifications-equal?): Remove variable.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-13 10:17:16 +01:00
Ludovic Courtès
25cb98f541
remote-worker: Update comment about topological ordering.
* src/cuirass/scripts/remote-worker.scm (run-build)[run-build-plan]:
Update comment about topological ordering.
2024-12-10 12:10:13 +01:00
Ludovic Courtès
03c79dc5ad
templates: Defend against corner case on build page.
* src/cuirass/templates.scm (build-details): Protect against
‘find-dependency’ returning #f.
2024-12-10 12:10:12 +01:00
Ludovic Courtès
2bbc7a4c40
templates: Fix typo error on evaluation pages for inactive jobsets.
* src/cuirass/templates.scm (evaluation-info-table): Add ‘assert’.
Remove extra ‘symbol->string’ calls for the inactive case.
2024-12-10 12:10:12 +01:00
Ludovic Courtès
1331acfdb6
utils: Add ‘assert’ macro.
* src/cuirass/utils.scm (&cuirass-assertion-failure): New exception type.
(assert): New macro.
2024-12-10 12:10:12 +01:00
Ludovic Courtès
e96f088792
register: Add ‘--derivation-ttl’ option, default to twice ‘--ttl’.
Mitigates <https://issues.guix.gnu.org/73916>.

* src/cuirass/base.scm (delete-old-gc-roots): Add #:derivation-max-age
and honor it.
(spawn-gc-root-cleaner): Likewise.
* src/cuirass/scripts/register.scm (show-help, %options): Add
‘--derivation-ttl’.
(cuirass-register): Use it as #:derivation-max-age to
‘spawn-gc-root-cleaner’.
* doc/cuirass.texi (Invocation): Document ‘--derivation-ttl’.
2024-10-21 17:31:56 +02:00
Ludovic Courtès
304c09badf
base: Be more conservative in deciding whether to remove a .drv GC root.
Possibly fixes <https://issues.guix.gnu.org/73916>.

* src/cuirass/base.scm (derivation-queued?): Return true if DRV is
‘failed-dependency’ and there are pending builds in its evaluation.
2024-10-21 16:57:28 +02:00
Ludovic Courtès
3af1abc2a2
database: ‘db-get-build’ is no longer in terms of ‘db-get-builds’.
This custom query is expected to perform better than the generic one in
‘db-get-builds’.

* src/cuirass/database.scm (db-get-build): Rewrite with a custom query.
2024-10-21 16:45:42 +02:00
Ludovic Courtès
fa76aed714
database: Remove ‘products’ field from <build>.
This simplifies ‘db-get-builds’ and the underlying SQL query, hopefully
making it faster.  The only uses of ‘build-products’ are in (cuirass
http) and they can cope with the extra SQL query.

* src/cuirass/database.scm (<build>)[products]: Remove.
(build-products): New procedure.
(db-get-builds)[format-build-products]: Remove.
Remove “INNER JOIN BuildProducts” and everything related to it.
2024-10-21 14:16:39 +02:00
Ludovic Courtès
74444bac17
database: Use ‘list->sql-array’ throughout.
* src/cuirass/database.scm (db-get-build-percentages): Use
‘list->sql-array’.
(db-get-jobs): Likewise, and remote ‘format-names’.
(db-get-jobs-history): Likewise.
(db-add-build-dependencies): Likewise.
(db-get-builds): Likewise.
(db-get-evaluations-absolute-summary): Likewise.
(db-worker-current-builds): Likewise.
2024-10-21 14:00:38 +02:00
Ludovic Courtès
79190e4352
remote-server: Move back to rescheduling builds asynchronously.
This undoes 5e59127179 and
6cd1608e64.

That approach was bogus for two reasons: first because the logic in
‘db-update-build-status!’ was wrong since we cannot tell whether the
previous attempt of the *same* build failed.  Second because the “update
status of dependent builds” operation is too expensive when the ‘Builds’
table has lots of rows.

* src/cuirass/database.scm (db-reschedule-dependent-builds): Remove.
(db-reschedule-builds-without-failed-dependencies): New procedure; this
is ‘db-update-resumable-builds!’ as it was removed in
6cd1608e64.
(db-update-build-status!): Remove call to
‘db-reschedule-dependent-builds’.
* src/cuirass/scripts/remote-server.scm (serve-build-requests): Send
'failed-dependency to BUILD-MAINTAINER.
* src/cuirass/base.scm (build-maintainer): Remove ‘&timeout’.  Expect a
symbol on CHANNEL and honor it.  Change default #:period to (* 10 60).
(spawn-build-maintainer): Change default #:period to (* 10 60).
* tests/database.scm ("status of dependent builds"): Add call to
‘db-reschedule-builds-without-failed-dependencies’.
2024-10-18 22:29:00 +02:00
Ludovic Courtès
655ba0a0a5
templates: Support commit URLs for codeberg.org (Forgejo).
* src/cuirass/templates.scm (%vcs-web-views)
(%vcs-web-commit-range-views): Add entry for codeberg.org.
2024-10-17 21:17:42 +02:00
Ludovic Courtès
fc4624cdac
templates: Add more ‘uri-encode’ calls for jobset URLs.
This is a followup to e53d596ca2.

* src/cuirass/templates.scm (build-details): Add call ‘uri-encode’ for
jobset URL.
(evaluation-build-table): Likewise.
2024-10-06 21:43:03 +02:00
Ludovic Courtès
d52a9c5630
base: Go back to marking ‘failed-dependency’ builds asynchronously.
This undoes part of 5e59127179 and
6cd1608e64, motivated by the fact that
marking dependents as ‘failed-dependency’ is too expensive (when there
are many ‘Builds’ rows) to be done from ‘db-update-build-status!’.

* src/cuirass/base.scm (build-maintainer, spawn-build-maintainer): New
procedures.
* src/cuirass/database.scm (db-update-build-status!): Remove call to
‘db-mark-failed-dependency-builds’.
(spawn-periodic-updates-fiber): Remove.
* src/cuirass/scripts/remote-server.scm (serve-build-requests):
Add #:build-maintainer and honor it.
(cuirass-remote-server): Remove call to ‘spawn-periodic-updates-fiber’.
Add call to ‘spawn-build-maintainer’.
* tests/database.scm ("dependents marked as 'failed-dependency'")
("status of dependent builds"): Add calls to
‘db-mark-failed-dependency-builds’.
2024-10-06 21:43:03 +02:00
Ludovic Courtès
35b7782182
utils: Add ‘atomic-box-fetch-and-increment!’ and ‘atomic-box-fetch-and-decrement!’.
* src/cuirass/scripts/remote-server.scm (atomic-box-fetch-and-update!)
(atomic-box-fetch-and-inc!, atomic-box-fetch-and-dec!): Move to…
* src/cuirass/utils.scm (atomic-box-fetch-and-increment!)
(atomic-box-fetch-and-decrement!): … here.
2024-10-06 21:43:02 +02:00
Ludovic Courtès
0042ce2a83
database: Set ‘starttime’ and ‘stoptime’ for ‘failed-dependency’.
Previously, builds that were immediately marked as ‘failed-dependency’,
from the ‘db-add-build-dependencies’ call, would have their ‘starttime’
and ‘stoptime’ set to zero.

* src/cuirass/database.scm (db-mark-as-failed-if-dependencies-failed):
Set ‘starttime’ and ‘stoptime’.
2024-10-05 22:54:13 +02:00
Ludovic Courtès
eb4771308e
http: Change /build/ID/restart from ‘GET’ to ‘POST’.
Not all crawlers honor ‘robots.txt’ and some could end up restarting
random failed builds (not surprisingly, perhaps!).

* src/cuirass/http.scm (url-handler): Change /build/ID/restart to POST.
* src/cuirass/templates.scm (build-details): Change “Restart” drop-down
menu item to a POST form with a button.
* tests/http.scm ("/build/1/restart redirects to /admin")
("/build/3/restart is unprivileged (failed build)"): Adjust accordingly.
2024-10-05 22:17:59 +02:00
Ludovic Courtès
e611adcca7
database: Optimize ‘db-get-builds-{min,max}’.
This query would be very slow:

  LOG:  duration: 10805.150 ms  plan:
	  Query Text: SELECT stoptime, id FROM Builds
	  WHERE evaluation =  $1  AND
	  (( $2  = 'pending' AND Builds.status < 0) OR
	   ( $3  = 'succeeded' AND Builds.status = 0) OR
	   ( $4  = 'failed' AND Builds.status > 0) OR
	   ( $5  = 'newly-failed' AND Builds.status =  $6
	    AND Builds.weather =  $7 ) OR
	     $8 ::text IS NULL)
	  ORDER BY stoptime DESC, id DESC
	  LIMIT 1
	  Limit  (cost=0.43..213.80 rows=1 width=8)
	    ->  Index Scan using builds_stoptime_id on builds  (cost=0.43..283141.54 rows=1327 width=8)
		  Filter: (evaluation = 242640)

Its plain direct counterpart appears to be more efficient:

  cuirass=> explain analyze select stoptime,id from builds where evaluation = 242640 and builds.status = 0 order by stoptime desc, id desc limit 1;
								    QUERY PLAN

  -----------------------------------------------------------------------------------------------------------------------
  -----------------------
   Limit  (cost=0.43..464.06 rows=1 width=8) (actual time=6197.445..6197.447 rows=1 loops=1)
     ->  Index Scan using builds_stoptime_id on builds  (cost=0.43..295794.55 rows=638 width=8) (actual time=6197.443..61
  97.443 rows=1 loops=1)
	   Filter: ((evaluation = 242640) AND (status = 0))
	   Rows Removed by Filter: 4597414
   Planning Time: 0.240 ms
   Execution Time: 6197.527 ms
  (6 rows)

  Time: 6198.353 ms (00:06.198)

* src/cuirass/database.scm (db-get-builds-boundary): New procedure,
based on ‘db-get-builds-min’.
(db-get-builds-min, db-get-builds-max): Rewrite in terms of
‘db-get-builds-boundary’.
2024-10-05 22:17:30 +02:00
Ludovic Courtès
d894a914f6
database: Add ‘with-timing-check’ for operations on dependencies.
* src/cuirass/database.scm (db-reschedule-dependent-builds): Wrap
‘exec-query/bind’ in ‘with-timing-check’.
(db-mark-as-failed-if-dependencies-failed): Likewise.
(db-mark-failed-dependency-builds): Likewise.
2024-10-05 12:02:22 +02:00
Romain GARBAGE
e53d596ca2
templates: Encode specification name when generating URL.
* src/cuirass/templates.scm (specifications-table): Encode specification name when generating URL.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-03 11:53:23 +02:00
Ludovic Courtès
0abf39033c
database: Rephrase logged sentence.
* src/cuirass/database.scm (db-reschedule-stale-builds): Rephrase.
2024-10-02 16:48:49 +02:00